-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
periph/timer: Change timer_init API to support arbitrary (integer) frequencies #4040
periph/timer: Change timer_init API to support arbitrary (integer) frequencies #4040
Conversation
This is to prepare the API for some xtimer changes (#3990) which will be necessary for low power operation on some platforms (Kinetis and others). |
373df4d
to
2f555c7
Compare
Size seem to have gone up marginally on most platforms. The 2 kB save on Kinetis is due to the rewrite of the prescaler calculation.
|
What do you think about adding a prescaler value? Just a signed int. Negative means "right shift the freq parameter by N", positive means "left shift". Otherwise, the current signature allows only timers with 2^32 Hz, while many hardware timers can do a lot more. |
@kaspar030 basically what you describe is encoding the frequency as a floating point value. Do you want me to update the signature to |
@gebart Wouldn't that introduce floating point code dependencies? Do you have another idea on how to allow >4MHz timer speeds? |
@kaspar030 that's not 4MHz, it's 4GHz that is the limit. While I do have some radio hardware which uses a 48 GHz clock internally, it is mostly non-configurable, and very specific to its use case (measuring time of flight for radio waves). Can we extend this API further when we see a use case for general purpose 4+ GHz timers? |
Can we extend this API further when we see a use case for general purpose 4+ GHz timers?
Sorry, I honestly miscounted the zeroes. 4ghz is totally enough.
|
@kaspar030 is that an ACK for the API change? |
2f555c7
to
2e57873
Compare
rebased on latest master |
I collected some HW on my desk and may test on arduino-due, nucleo-f091, stm32f0discovery.
Can you be more specific about some time? :-) I ran xtimer_msg for ~45min. Is that enouth? |
Testing for a few minutes should be enough. I saw a problem before where the xtimer_usleep_until test simply stopped after a few seconds, but that was a symptom of a timer running at a much higher speed than what xtimer believed it to be running at, in combination with some other messed up settings and possibly the xtimer bug that was identified and fixed yesterday by Kaspar and Daniel. To test thoroughly we need to run it for at least 4300 seconds (until overflow), but I don't think this will be necessary for this API change. It should not affect the overflow behaviour. |
@A-Paul ping! |
2e57873
to
8dd8386
Compare
On arduino-due, nucleo-f091, stm32f0discovery and pba-d-01-kw2x all I had issues to get terminal connection with our nucleo-f303, so I couldn't test. Will try again tomorrow on campus. |
Also checked nucleo-f303. Everything is fine. |
8dd8386
to
6bced0c
Compare
|
397a942
to
f76ecd1
Compare
Updated the nrf52 with the exact same change as the nrf51 ( |
Travis is green. |
Should I squash this or leave it as separate commits for each CPU? The code will not be able to build for the intermediate commits, only after all commits are merged. But on the other hand, the squashed commit will be huge.. |
changes for the |
YAY! |
periph/timer: Change timer_init API to support arbitrary (integer) frequencies
Hooray! Congrats and thanks for the awesome work. Btw with this PR we just crossed another frontier: 10,013 commits! |
nice! |
This PR modifies the timer_init function to take a frequency parameter instead of another mostly unused us per tick or tick per us parameter.
The rationale is that with the previous API there is no way to request a 32768 Hz timer, which is a common frequency for RTC crystals.
The new timer_init function has the following declaration:
Needs testing on all boards... sigh
Use tests/xtimer_msg, tests/xtimer_usleep_until etc for testing.
Things to look out for:
Test complete.
should be printed at the end if all goes well)Testing checklist:now=253.098701 (0 hours 4 min), diff=0
stm32f4: UART DMA causes lockup in xtimer_drift test #4716