The project uses FREERTOS.
Once CAN is configured and filters are set, I call HAL_CAN_Receive_IT : OK
On receiving a CAN frame, HAL_CAN_RxCpltCallback is called : OK
In HAL_CAN_RxCpltCallback, a signal is sent to a thread to handle the frame.
The thread receiving the signal, reads the frame an then calls HAL_CAN_Receive_IT for next frames : OK
At some time, the application calls HAL_CAN_Transmit_IT to send a frame : OK
When the frame is sent, HAL_CAN_TxCpltCallback is then called : multiple times...
It is not only called when the frame is sent, it is also called when a frame is received, because in stm32f1xx_hal_can.c, the function HAL_CAN_Receive_IT enables "Transmit mailbox empty Interrupt" ( CAN_IT_TME ).
I think it should not !
All CAN IRQ Handlers generated by STM32CudeMX calls the same function HAL_CAN_IRQHandler in stm32f1xx_hal_can.c.
CAN_Transmit_IT is called because CAN_IT_TME has been enabled and the status of CAN_TXMAILBOX_* haven't changed.
Removing "CAN_IT_TME" in HAL_CAN_Receive_IT solved the problem for me.
Best regards, Frédéric.