cancel
Showing results for 
Search instead for 
Did you mean: 

64-bit timer in STM32L4S5ZI

SJant.1
Associate III

Hi,

I am using STM32L4S5ZI which has only a timer with maximum capacity of 32-bit. The DWT(Data Watchpoint Trigger) is somehow not available because when I check for DWT->CNT it always shows 0. So I needed a 64-bit timer for my application which keeps on running and I can read it whenever I need the time.

Is there any way by means of which I can somehow use the 2 32-bit timers available and make them together as a single 64-bit timer?

I do not want to use the Period_elapsed interrupt and keep track of the overflown time. So please let me know if I have any other way possible..

Thanks

4 REPLIES 4
SJant.1
Associate III

Somewhere I read about chaining two timers, like chaining two 32 bit timers to 64 bit timer. But there was no clear explanation.

If anyone can throw some light on this then it would be really helpful.

Uwe Bonnes
Principal II

Run some timer that you sample faster than half the timer period. When you sample, compare to the last sample and when new sample is smaller than last sample, increment some variable to generate the missing bits to 64 bit. When you need to use the combined value do the same sampling. Make sure you both actions do not step on the others feet.

Yes, you'd chain TIM2 TIM5 in a gated mode, I don't have an example to hand for the L4, but there are likely examples for the other STM32 families using paired 16-bit timer that would morph similarly to a pair of 32-bit ones and also in ST's TIM Cookbook

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Piranha
Chief II

> The DWT(Data Watchpoint Trigger) is somehow not available because when I check for DWT->CNT it always shows 0.

You have to enable it!