Understanding System Timer

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

Moderators: RoccoMarco, barthess

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

Understanding System Timer

Postby JSStabl » Thu Dec 03, 2020 3:40 pm

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: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Understanding System Timer

Postby Giovanni » Thu Dec 03, 2020 7:47 pm

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

Postby JSStabl » Fri Dec 04, 2020 10:49 am

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: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Understanding System Timer

Postby Giovanni » Fri Dec 04, 2020 2:12 pm

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

Postby JSStabl » Wed Dec 09, 2020 3:35 pm

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

Will run the test suite on a nucleo board.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 55 guests