Question
CAN Bus Error Management
Posted on April 17, 2015 at 13:06
Hey guys, using the STM32F4 + cube, I setup a CAN device which works good until I play around with disconnecting the CAN bus lines and reconnecting them. Doing so produces bus errors and I am not sure how to handle these errors in a recoverable way?
What I currently do (which is not working)When the CAN Error callback occurs:1) Disable CAN SCE (NVIC_DisbleIRQ(CAN2_SCE_IRQn))2) Set CAN into silent mode (BTR |= CAN_MODE_SILENT)3) Disable the error flag (IER &= ~CAN_IER_ERRIE)4) Set a 5-second timer that is used by the RTOS to try to recover. During this 5-second timer I disable all CAN Rx/Tx handling (bypass my CAN manager task)When the 5-second timer expires, I do this:1) Reset silent mode (BTR &= ~CAN_MODE_SILENT)2) Re-enable the SCE interrupt (NVIC_EnableIRQ(CAN2_SCE_IRQn))3) Re-enable error flagIER |= CAN_IER_ERRIEThe CAN bus does not recover however...Anyone have any ideas as to what else I should be doing?Many thanks! #can-bus