2015-04-17 04:06 AM
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-bus2015-04-17 04:46 AM
IMHO you must also check BusOff flag in ESR register (CAN_ESR_BOFF).
2015-04-17 05:12 AM
So I have automatic bus of management (ABOM) turned off at the moment....Should I have turned it on?
Odd thing right now is that the BOFF never gets set even though TEC has exceed the BOFF threshold.....When exactly should I be checking for BOFF?2017-03-25 06:37 AM
Did you find a solution to have recoverable CAN device? I am working at this right now and I am strugling with finding proper steps to take after
e
rror occurred. When I disconnect bus and try to transmit some frames I get
HAL_CAN_ERROR_ACK
(HAL version 1.9.0) which is expected, but right now I don't see any other solution except
restarting the whole interface to get it work again after each error occurence.