Page 1 of 1

Understanding System Timer

Posted: Thu Dec 03, 2020 3:40 pm
by JSStabl
I'm trying to understand the system timer, specifically how to set the frequency. I'm working on a STM32F7. As Giovanni explained in this thread:
viewtopic.php?t=4995#p34767 must be a multiple of a 16 bit prescaler.

The F7 works with a 108Mhz prescaler (at least by default that is), so setting 10000 should not work (as used as an example above). However exactly the used as a default value for the F7 in the https://github.com/ChibiOS/ChibiOS/blob/master/demos/STM32/RT-STM32F767ZI-NUCLEO144/cfg/chconf.h#L55 demo repo, I've been using the default value for some time now. How does that work?

I have a thread that gets called every 64us and want to measure that with the systick. Easiest way is to just make it faster.
What are the disadvantages for turning up the CH_CFG_ST_FREQUENCY value by 10x for example?

Also: Is there an easy way to convert the SYSTICK to nanoseconds? I tried to adapt the uc version but with no success so far.

Re: Understanding System Timer

Posted: Thu Dec 03, 2020 7:47 pm
by Giovanni
JSStabl wrote: have a thread that gets called every 64us and want to measure that with the systick. Easiest way is to just make it faster.
What are the disadvantages for turning up the CH_CFG_ST_FREQUENCY value by 10x for example?


Yes, it is possible but then you have to play with the delta parameter and it can be tricky, basically you need to increase it until it works stably.

JSStabl wrote:Also: Is there an easy way to convert the SYSTICK to nanoseconds? I tried to adapt the uc version but with no success so far.


No there are only conversion macros for seconds, milliseconds and microseconds. You should be able to do a conversion macro yourself, using the microseconds one as example.

Giovanni

Re: Understanding System Timer

Posted: Fri Dec 04, 2020 10:49 am
by JSStabl
I increased the CH_CFG_ST_FREQUENCY to 1Mhz (from the original 10khz) and it seems to work fine. What kind of tests would you recommend to test if its stable?

Re: Understanding System Timer

Posted: Fri Dec 04, 2020 2:12 pm
by Giovanni
Hi,

Just run the test suite, have you also increased the delta parameter?

Giovanni

Re: Understanding System Timer

Posted: Wed Dec 09, 2020 3:35 pm
by JSStabl
No I haven't just seemed to work fine without adjusting that.

Will run the test suite on a nucleo board.