diff options
author | Martin Fischer <fischer.carlito@gmail.com> | 2020-07-02 22:19:00 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-07-08 23:47:02 +1000 |
commit | 15574cd665a8e66157aa97447e3869513da81d45 (patch) | |
tree | f75a1f0535d0d78150c7b55473cfbefd885608cc /py/parsenum.c | |
parent | c2317a3a8d5f184de2f816078d91be699274b94e (diff) |
nrf: Add support for time.ticks_xxx functions using RTC1.
This commit adds time.ticks_ms/us support using RTC1 as the timebase. It
also adds the time.ticks_add/diff helper functions. This feature can be
enabled using MICROPY_PY_TIME_TICKS. If disabled the system uses the
legacy sleep methods and does not have any ticks functions.
In addition support for MICROPY_EVENT_POLL_HOOK was added to the
time.sleep_ms(x) function, making this function more power efficient and
allows support for select.poll/asyncio. To support this, the RTC's CCR0
was used to schedule a ~1msec event to wakeup the CPU.
Some important notes about the RTC timebase:
- Since the granularity of RTC1's ticks are approx 30usec, time.ticks_us is
not perfect, does not have 1us resolution, but is otherwise quite usable.
For tighter measurments the ticker's 1MHz counter should be used.
- time.ticks_ms(x) should *not* be called in an IRQ with higher prio than
the RTC overflow irq (3). If so it introduces a race condition and
possibly leads to wrong tick calculations.
See #6171 and #6202.
Diffstat (limited to 'py/parsenum.c')
0 files changed, 0 insertions, 0 deletions