2025-11-24 8:39 AM
In rm0316 rev 10 for the stm32F303x, the documentation for the ABRQ bits in the CAN_TSR transmit status register states:
Setting this bit has no effect when the mailbox is not pending for transmission.
I am finding on my STM32F303 that setting ABRQx when the mailbox is empty will actually clear the RQCPx and TXOKx status bits in the CAN_TSR.
This effect is important to note, because if you're using the TXOKx bit to determine if the message was transmitted or aborted and ABRQx was set after the mailbox finishes its transmission and becomes empty, you will think the message was successfully aborted (because TXOKx is cleared by the late abort) when it was actually transmitted.
Even if you disable interrupts and check the mailbox status immediately before setting the ABRQx bit, it seems like there is still a race condition where the mailbox transmission could complete between the read and write operations, which could occasionally cause the abort to be late. Is there a way to do this atomically?
A workaround that seems to work is to check both RQCPx=0 and ABRQx=0 after an abort request to determine if the abort request came in after the message was transmitted, but this appears to be undocumented behavior.
Thanks for listening and any suggestions or documentation I may have missed.