64bit system timer issues

Discussions and support about ChibiOS/RT, the free embedded RTOS.
Post Reply
DrTon
Posts: 6
Joined: Sat Oct 22, 2016 9:30 pm

64bit system timer issues

Post by DrTon »

Hello!

On ChibiOS/RT 20.3 (https://github.com/ChibiOS/ChibiOS/tree/stable_20.3.x) I'm trying to switch system timer to 64 bit mode.
If system tick frequency is 10 000 everything works. But if I change it to 1000 000 (I need 1 microsecond time precision) or even 100 000, then everything goes wrong, e.g. chThdSleep() sleeps for incorrect time (and every time different).

In 32 bit mode everything works fine.
Didn't find any demos in 64 bit mode, is it fully supported?

```
CPU: STM32F765II

#define CH_CFG_ST_RESOLUTION 64
#define CH_CFG_ST_FREQUENCY 100000
#define CH_CFG_INTERVALS_SIZE 64
#define CH_CFG_TIME_TYPES_SIZE 32
#define CH_CFG_ST_TIMEDELTA 2

#define STM32_ST_USE_TIMER 5
```
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: 64bit system timer issues

Post by Giovanni »

Hi,

Try increasing the delta parameter, it is required when going to higher frequencies, you need to find the value experimentally because it depends also on the duration of your timer callbacks. Keep assertions enabled while doing this.

Giovanni
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: 64bit system timer issues

Post by steved »

If you don't need "global" 1us resolution, have a look at the last post here. It uses a separate counter to implement a high resolution virtual-timer style timer. Might need a little tweaking for your platform. I've also done something similar limited to the two or four comparators of a timer; limits the number of active timers, but less overhead.
Post Reply