STM32U575 TIM1 Capture Compare interrupt fails to count pulses of a temperature sensor
- May 7, 2023
- 7 replies
- 3800 views
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:
- Relate and confirm if our case of counting pulses is relevant to be handled using the TIM1 with Capture Compare interrupts?
- Can you review and comment on our setup and configuration as detailed here above?
- Can you point us to some code samples/detailed "cookbook" to handle correctly Capture Compare Timer functionality?
Thank you
Roni
