‎2023-05-07 07:23 AM
Hello
TIM1 Capture Compare interrupt of STM32U575 - fails to count pulses of a temperature sensors connected to its channels.
We use few temperature sensors of the same kind: LMT01 of TI
Connected are four such temperature sensors to each of the four channels of TIM1.
Each sensor produces the pulses number according to the temperature.
There is a time-window, tCONV, of maximum 54[msec] (it may vary between 46-54, typical is 50) where the sensor performs the conversion itself (of temperature to the required number of pulses to be produced),
followed by a time-window, tDATA, of maximum 50[msec] (it may vary between 44-50, typical is 47) , where the sensor actually produces the pulses.
The individual pulse frequency is typically 88 kHz (it may vary between 82-94khz).
Please see attached a snapshot of the timing diagram.
Also, we have checked with a scope that indeed such pattern is produced by each of the temperature sensors.
But using the TIM1 configured to 100[khz] (>88[khz)), and to generate TIM1 Capture Compare interrupt, it seems to fail to count the pulses correctly: it either calculate less or more (for example: room temperature 25 [Celsius] we get either ~800 or ~1500 pulses, instead of ~1200). Also configured are four channels of TIM1 (please see attached all configuration done in STM32CubeIDE - just missing from the snapshot is settings we did to achieve 100[khz] of TIM1: Prescaler set to 64-1, Counter Period (ARR) set to 10-1, according to the formula: Timer frequency = (timer clock frequency) / (prescaler x auto) and HCLK is 64[Mhz].
We use a simple logic in our software to count the pulses.
This logic is called from HAL_TIM_IRQHandler() via HAL_TIM_IC_CaptureCallback() called for each channel.
Could you please:
Thank you
Roni
‎2023-05-07 09:20 AM
i dont understand, which way you want count pulses by using ONE timer and 4x cc inputs .
you get just a useless delay captured...then you count in callback - right ?
why not kiss : use the pin change INT and simply count in the interrupt the value up,
+ set some (30ms ?) timeout: when >30ms no counts on a pin, get value and reset it to zero, for next value.
‎2023-05-07 09:41 AM
Hi Ascha.3
Thanks for your reply!
Thank you
Roni
‎2023-05-07 10:26 AM - edited ‎2023-11-20 06:13 AM
ad 1: set rising/falling detection on 4 or more pins , as you like ->
then process in INT , count++ ... timeout , etc.
ad 2: shure, it will make an int also, but ... why create complex setup, just to get a pin change level ?
‎2023-05-07 11:07 AM
Your problem is the bloated Cube/HAL interrupt system (and maybe also too low compiler optimization setting). Just ditch Cube and write your own interrupt handler.
Another method would be to use timers in External clock mode; they are easily capable counting in megahertzs, but the drawback is that there's only one counter per timer, so you'd need to use 4 timers for the 4 input signals.
JW
‎2023-05-07 12:14 PM
My guess is that the timer counter running close to the frequency of 4 signals creates synchronization problems. Up the timer frequency to 1 or perhaps even 10 MHz.
‎2023-05-15 01:39 AM
Have you found your answer?
‎2023-05-15 02:02 AM
No, we could not make the TIM1 Capture Compare work to count the pulses of our temperature sensors.
We temporary use simple interrupts mechanism for that purpose.
But interrupts might be needed for other purposes in our system, and we could benefit from having the TIM1 Capture Compare work for us.
‎2023-05-15 04:27 AM
Have you assigned higher interrupt priority?
Have you used higher optimization settings of compiler?
Have you tried to get rid of Cube's interrupt mechanism, and write your own ISR?
Have you tried to use the external clock mode?
JW