Understanding System Timer

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
JSStabl
Posts: 78
Joined: Tue Feb 25, 2020 4:06 pm
Has thanked: 3 times
Been thanked: 2 times

Understanding System Timer

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Understanding System Timer

Post 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
JSStabl
Posts: 78
Joined: Tue Feb 25, 2020 4:06 pm
Has thanked: 3 times
Been thanked: 2 times

Re: Understanding System Timer

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Understanding System Timer

Post by Giovanni »

Hi,

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

Giovanni
JSStabl
Posts: 78
Joined: Tue Feb 25, 2020 4:06 pm
Has thanked: 3 times
Been thanked: 2 times

Re: Understanding System Timer

Post by JSStabl »

No I haven't just seemed to work fine without adjusting that.

Will run the test suite on a nucleo board.
Post Reply