Skip to main content
hdemi.1
Associate III
September 29, 2022
Question

Which is the best way count over 1G with a 16-bit timer ?

  • September 29, 2022
  • 1 reply
  • 503 views

I need to count over 1G with a 16-bit timer, measurement accuracy is very important to me. I had to do it using a single timer, do you have any suggestions? I am using stm32f0 ant timer1

Thank you

This topic has been closed for replies.

1 reply

waclawek.jan
Super User
September 29, 2022

You need to combine the TIM1_CNT with some "upper-bits" counter.

Either use master-slave (TRGO-TRGI) connection to other timer, master generating TRGO upon Update, and slave being set to external clock mode; or simply in Update interrupt of TIM1 increment a variable which represents the uppermost bits of your "combined counter".

In any case, when reading out the value, as there's no native way to read both parts of the "combined counter" at the exactly same time, you have to use the usual "read upper 1 - read lower - read upper 2 - if upper1 != upper2 repeat all" procedure.

JW