STM32H7 USART FIFO + character match: CMF not set until FIFO is actually read?
As the subject line says, I've written a USART driver for a STM32H755 project where I want to detect a special end-of-line character, for implementing a simple command-line interface.
Originally this used DMA with the USART FIFOs disabled, but I recently changed the driver to use the 16-deep FIFOs with FIFO-threshold interrupts, because I am bit short on DMA channels.
I couldn't figure out why the character-match interrupt wasn't firing, so I paused execution to look at the USART registers after sending a short (12 characters) command from my serial terminal. I then refreshed the register view while looking at USART->RDR and was able to see the characters stored in the FIFO come out one by one.
Finally after the 12 bytes my "match" character appeared in RDR and then the CMF bit was set in ISR. This was what I was afraid of. The RM alludes to the fact that the receive FIFO stores some flags along with each received character. Well, apparently one of those flags is CMF.
I think this falls into that category of "technically correct but renders the functionality useless." If I'm interpreting correctly, the character-match function doesn't do anything useful when the USART FIFO is active. You want an interrupt to tell you that your magic character has arrived, but you won't get it unless you are reading the bytes one by one, obviating the need for a FIFO in the first place.
I would argue that this should be a chip errata, except it appears to be by design.
I'm posting here both for posterity, but also in the slim hope that someone will challenge my interpretation and tell me why it's wrong (and how to fix it without using DMA or getting an interrupt on every character).
Thanks.
