cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Bus Error Management

bdesantis
Associate II
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 flag

IER |= CAN_IER_ERRIE

The CAN bus does not recover however...Anyone have any ideas as to what else I should be doing?

Many thanks!

#can-bus
3 REPLIES 3
vromanov
Associate II
Posted on April 17, 2015 at 13:46

IMHO you must also check BusOff flag in ESR register (CAN_ESR_BOFF).

bdesantis
Associate II
Posted on April 17, 2015 at 14:12

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?

Zbigniew Szeliga
Associate
Posted on March 25, 2017 at 14:37

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.