If an error callback function is installed via FLEXCAN_DRV_InstallErrorCallback, it enables error interrupts (internal error, rx warning, tx warning, busoff). However, there's only one interrupt handler FLEXCAN_Error_IRQHandler, it calls error_callback function with event type FLEXCAN_EVENT_ERROR.
I don't know the root cause why the error interrupt is triggered.
If I want to get busoff status of the CAN bus, what can I do to implement it?
At the same time, if I want to get the internal error status, how do I distinguish the INT_ERR and INT_BUSOFF?
Hello 文明 徐,
To generate the bus-off error the easiest way to do this is to send a message to an ID that is not in the network after some tries and error counter reaches 255 the bus-off condition will be triggered.
Also, in the ESR register the different errors that the module register, you could check the description at the following section in the reference manual:
It seems that I didn't make the question very clear.
I'm not generating the bus-off error, I need to detect the error when bus-off condition is triggered.
Hello 文明 徐,
The flags in the ESR1 are clear after calling the callback, so if you check the BOFFINT flag in the callback you should be able to identify the bus off event.