2024-12-03 04:52 PM
Hi everyone,
I’m working on an STM32C0 setup where TIM1 CH1 (Pin A) and UART RX (Pin B) are physically shorted together, and I’ve encountered some unexpected interrupt behavior. Specifically, the UART RXNE interrupt always triggers before the TIM1 Capture Compare (CC) interrupt when the UART receives a byte 0x00.
TIM1 Configuration:
UART Configuration:
The goal is to establish precise timing for sensor data communication:
When the UART master sends a byte 0x00, the UART RXNE IRQ consistently triggers before the TIM1 Capture Compare IRQ, even though TIM1 has a higher IRQ priority.
I debugged this using breakpoints on both IRQ functions, and RXNE always executes first.
I expected the TIM1 CC IRQ to trigger first since:
However, the observed behavior is the opposite: RXNE consistently triggers ahead of TIM1 CC.
Any insights or suggestions to help me understand this behavior or resolve it would be greatly appreciated. Thanks in advance!
2024-12-04 03:09 AM
> when the UART receives a byte 0x00
Is that byte correctly terminated by stopbit, i.e. has the correct duration for startbit+8 data bits?
Are there any status bits set by UART?
JW
2024-12-04 03:58 AM
The behavior makes sense. UART RX may be triggered at 9/16 of stop bit period. It should make no difference to you, as the timer correctly records the timestamp. You may service the UART RX in timer interrupt, having RXNE interrut disabled while waiting for the sync frame. Also, you could detect high-to low transition of start bit instead. So: not really a problem; few solutions available.
2024-12-04 02:12 PM
> UART RX may be triggered at 9/16 of stop bit period
Stopbit is 1 so that's already beyond the 0-1 transition which should trigger the TIM capture. Provided that the byte is correctly timed, that is. That's why my question above.
JW