Report
2 months, 1 week ago.

Reading CAN status

Someone told me, that for some reason (power issues for instance) the can communication can break. To be able to send and receive messages after such an event, the CAN communication has to be reset. To see, if there is a problem, the CAN status has to be read periodically. Is that true and if yes, can someone provide me with as small example please? - I tried to check the API documentation for rderror and tderror on https://developer.mbed.org/handbook/CAN, but the links are broken: Invalid page name You tried to access or create a page named classmbed_1_1CAN.html. Unfortunately, that name is not permitted as the name for a wiki page.

Comment on this question

1 Answer

2 months ago.

Hello Peter,

The following link provides some info on low-layer CAN bus protocol error handling.

https://www.kvaser.com/about-can/the-can-protocol/can-error-handling/

Automatic recovery from bus-off state is available on CAN controllers built-into the STM microcontrollers and the feature is utilized by the CANnucleo library.

The CAN-based higher-layer protocols, like CANopen, then introduce additional methods (node guarding, heartbeats ...) to check/monitor the status of CAN nodes in the network.

Hello Zoltan, thank you for your answer!

Does that mean, that my NUCLEO-L432KC will automatically take care of the bus-off situation?

I am not using CANopen, I am just working with the mbed library. - Do I need following line in my code:

if (can.tderror() >= 255) can.reset();

I just want to take care about the bus-off situation.

posted by Peter Seidel 21 Jul 2017

Hellow Peter,
Unfortunately mbed's CAN API does not utilize automatic buss-off management (ABOM) most likely because some mbed platforms do not implement such feature. However, for the STM platform you can turn it on for example as follows:

  • In your project replace the mbed library with mbed-dev.
  • Open "mbed-dev/targets/TARGET_STM/can_api.c" and change line #73 to

    CanHandle.Init.ABOM = ENABLE;
posted by Zoltan Hudak 29 Jul 2017

To post an answer, please log in.