← index #4377PR #5470
Off-topic · high · value 2.584
QUERY · ISSUE

nrf: add support for threading

openby george-xiongopened 2018-12-24updated 2019-05-21
port-nrf

hi Micropython,

could you please add thread to nrf as some cusotmer in china need micropython support multi-thread function. currently, it is not supported on nrf51&52 platform.
my email is george.xiong@nordicsemi.no

thanks.

Best regards
george

CANDIDATE · PULL REQUEST

ports/nrf: add support for time.ticks_ms()

closedby hoihuopened 2019-12-28updated 2020-07-10
port-nrf

The nordic port lacks support for a milisecond / microsecond tick
counter (and basically most of the time module functionality..).

The ms tick counter is needed by asyncio and prevents the usage
of this module, which is my primary design goal.

So I had a go and enabled the systick irq with 1msec resolution.
This enables the usage of a 32 bit counter rather than
on relying on the hw's systick timer 24bit width. But it does
add a bit of overhead. 32bit would overflow after 50 days - although
the pyhton return value might be restriceted to only 31 bits (?). 24 bits take app.
5h to overflow, which might be suitable too.

Inreasing the counter's width to 64bit would eliminate any overflow
handling on the python side, but may add some overhead on passing
this value from C to python (but I'm not sure how much).

Another option would have been to grab a separate HW timer unit, which could
probably be used in a better, power optimized manner and possibly
without irq's since they are 32bit width.

However I was reluctant to do this since for some MCU's a timer unit is precious.

So in summary, it was a surpring amount of factors to consider for
such a small change. Looking forward to some inputs/comments.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied