[riot-devel] EFM32 timers, PWM and xtimer
joakim.nohlgard at eistec.se
Fri Nov 16 08:22:38 CET 2018
If you want some inspiration for a timer driver you could take a look
at the Kinetis periph/timer driver which wraps two different timer
hardware modules underneath, one for high frequency and precise
control (PIT, always clocked by the CPU bus clock), and the other for
low power consumption and lower frequency (LPTMR, usually clocked by
the RTC oscillator, but there are other options as well).
Additionally, PR#7897 adds pm_layered management inside the timer
driver for the PIT to prevent low power modes from disrupting a timer
when there is a target set.
On Mon, Nov 12, 2018 at 7:29 PM chrysn <chrysn at fsfe.org> wrote:
> Hi Bas,
> thanks for your quick response!
> On Mon, Nov 12, 2018 at 05:54:09PM +0100, Bas Stottelaar wrote:
> > The newer chips have an additional 32-bit timer with the same problem, but
> > this frees up timers for PWM.
> That unfortunately won't help with the hardware I have here right now :-/
> > The two timers are needed, because they run in cascade mode. Only that way,
> > I can generate values for XTIMER_HZ that have sufficient resolution.
> As I understand, the timer that serves XTIMER needs to be precise 1MHz,
> and may be up to 6 shifts away from it -- but there is also the option
> of running it from a 32768Hz clock available as internal and often
> external clock. That seems to be sufficient xtimer resolution for some
> applications (it certainly is for mine).
> Options are a bit limited as to how to implement such a clock without
> moving the whole device on the low frequency clock (HFPERCLK TIMERn can
> only be clocked from LFxO if all HF stuff actually uses that in
> HFCLKSEL), but the LETIMER0 (or RTC, but LETIMER is unused) would be an
> option here (provided LFACLK comes from an LFxO).
> If LETIMER support were to be added, it could probably look similar to
> the changes in  -- but would need to branch out in timer_init, and
> (when it's a LETIMER) err out if the desired frequency is not 32768.
> : https://github.com/RIOT-OS/RIOT/pull/9878/files
> To use raw power is to make yourself infinitely vulnerable to greater powers.
> -- Bene Gesserit axiom
> devel mailing list
> devel at riot-os.org
More information about the devel