USART2_LPUART2_IRQHandler fired when no interrupts are enabled in control register
Hello,
The cpu is STM32G0B1. I am developing the interrupt-based UART driver using FIFO and software circular buffers. The main point is, that I don't fully understand the mechanism of interrupts. I enabled two interrupts in CR3 register using RXFTIE and TXFTIE bits. The thresholds I set to: RX - 1 byte present in fifo, TX - 0 bytes present in fifo (empty). As I mentioned earlier, I am also using software circular buffer with several bytes of size. The mechanism is rather simple - interface with periodic writing/reading to/from circular buffer and then interrupts are handling the rest. First thing is - if there is no data to be sent or, vice-versa, the software RX buffer is full, I do not want to touch TDR/RDR register - so in order to stop interrupts from triggering over and over (eventually triggering the watchdog) I am using RXFTIE and TXFTIE bits to disable the interrupts. I then enable them again in periodic read/write functions when there is some data to be transmitted/received. However, what is super weird, is that sometimes in the interrupt routine I check for the RXFTIE and TXFTIE and they are both zeros. How is that possible?
They are "ghost" interrupts. It is also possible to have interrupt fired with RXFT == 0 and TXFT == 0 in ISR register.
My interrupt routine looks like this:
if (RXFT)
Read whole RX fifo to circular buffer
else if (TXFT)
Write whole TX fifo with data from circular buffer
else
Count for "ghost" interrupts -> if more than 5 raise an error
