Skip to content

Conversation

jnohlgard
Copy link
Member

Depends on #3990, #4040, #4827, #4183

This PR modifies the periph/timer interface to use the low-power timer (LPTMR) for TIMER_0 and use that timer for the xtimer system. The LPTMR module has the benefit that it does not stop when entering any low power modes, so it can be used as a reliable timer source for a power saving radio MAC layer.

TIMER_1 and TIMER_2 are using the PIT module, which only runs when the CPU is in RUN or WAIT mode, i.e. full power.
The LPTMR module resets when stopping, so in order to prevent the timer from going backwards when setting a new time we use the RTT module as a reference point for lptmr_read(). This avoids the convoluted (sometimes even ineffective) extra measures that were used in the old hwtimer implementation to avoid dropping ticks on the LPTMR module.

This PR is somewhat controversial because it modifies the periph/timer driver to use three different hardware timers running at different frequencies.

@jnohlgard jnohlgard added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Platform: ARM Platform: This PR/issue effects ARM-based platforms State: waiting for other PR State: The PR requires another PR to be merged first Area: timers Area: timer subsystems labels Oct 8, 2015
@jnohlgard jnohlgard force-pushed the pr/kinetis-lptmr-timer branch from 9c29864 to 06b4b69 Compare October 23, 2015 13:19
@OlegHahm OlegHahm modified the milestone: Release 2016.03 Dec 8, 2015
@jnohlgard jnohlgard force-pushed the pr/kinetis-lptmr-timer branch from 06b4b69 to 0da0246 Compare February 16, 2016 07:58
@jnohlgard
Copy link
Member Author

Rebased on top of latest #3990

Joakim Nohlgård added 12 commits February 28, 2016 12:28
 - Safer handling of targets when using XTIMER_MASK
 - Reduce number of redundant branches
 - Avoid possible timer underflow when subtracting XTIMER_OVERHEAD
 - Spin at the end if target time is close
…CKOFF

If XTIMER_OVERHEAD is greater than either XTIMER_BACKOFF and/or
XTIMER_ISR_BACKOFF then it will be possible schedule low level timers
with a negative offset, which means the timer will delay until the next
overflow.
64-bit version of div_u32_by_15625div512

also updated tests-div to use correct order for expected and actual values in unit tests (embUnit)
Set XTIMER_HZ in periph_conf.h to specify the xtimer hardware timer
frequency.

The xtimer system uses the hardware timer's own tick representation
internally but a thin wrapper layer is added as a shim between xtimer
core and the public xtimer API which is based around microseconds as
the time unit.

Initially supports only 1000000 Hz (and powers-of-two divisions of it)
and 32768 Hz, but can easily be expanded by adding a new case for
XTIMER_HZ inside xtimer.h
@jnohlgard jnohlgard force-pushed the pr/kinetis-lptmr-timer branch from 2823eac to 98e598a Compare February 28, 2016 12:05
@OlegHahm
Copy link
Member

Seems unlikely to get ready for this release.

@jnohlgard
Copy link
Member Author

closed in favour of #5294

@jnohlgard jnohlgard closed this Apr 11, 2016
@jnohlgard jnohlgard deleted the pr/kinetis-lptmr-timer branch March 30, 2018 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: timers Area: timer subsystems Platform: ARM Platform: This PR/issue effects ARM-based platforms State: waiting for other PR State: The PR requires another PR to be merged first Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants