Skip to main content
SJant.1
Associate III
March 29, 2021
Question

64-bit timer in STM32L4S5ZI

  • March 29, 2021
  • 4 replies
  • 1465 views

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

This topic has been closed for replies.

4 replies

SJant.1
SJant.1Author
Associate III
March 29, 2021

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.

Tesla DeLorean
Guru
March 30, 2021

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
Uwe Bonnes
Chief
March 29, 2021

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.

Piranha
Principal III
April 2, 2021

> 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!