4 Common Issues/Pitfalls
In some cases, the IRXIF trigger will fail to immediately identify a CAN message as being at the incorrect baud rate, due to the CAN module interpreting it as a message with the correct baud rate with a different error. In this case, it is possible (depending on the current baud rate setting of the PIC MCU, the baud rate of the incoming message, and the mask/filter settings) that the receive buffer interrupt will instead trigger, as if a correct message was detected. However, in this case, the ERRIF flag will invariably be set, as the incorrect baud rate message will seem corrupted. As such, when performing the auto-baud sequence it can be useful to have code to handle this case, not exiting auto-baud if the error interrupt flag is set to avoid prematurely entering normal application mode. In this case, the error interrupt flag should also be cleared before exiting the interrupt service routine.
In addition, there are some cases in which the error interrupt flag cannot be cleared without first clearing the error condition. The most common of these is when the RXOVF bit is set (receiver overflow). This error flag is located in the COMSTAT register and is not cleared by hardware even when the receiver is cleared, and must be cleared manually before clearing the ERRIF flag in order for normal operation to continue.
Both of these considerations have been addressed in the autobaud example code located on MPLAB® XPRESS both by checking the ERRIF flag as well as checking the RXOVF bit and clearing it within the autobaud routine.