CAN bus error detection: How to detect short circuit with PSoC5LP?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
GuNo_288966
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Hi,

I have a custom board with a CY8C5888AXI-LP096 and a TJA1050 CAN transceiver.

CAN controller V3.0.

Transmission of data works fine.

Now I am having trouble to detect an error state.

When the bus is not connected, CAN_GetErrorState() replies 0x01 (passive), ok.

When CANH and CANL is shortened and released again, the CAN component stops sending data to the TJA1050.

I can not find how to detect this situation:

CAN_GetErrorState() returns 0

CAN_GetTSErrorFlag() returns 0

CAN_GetTXErrorCount() returns 0

When I then call CAN_Start(), the CAN component recovers and continues to send data.

The function CAN_ReadErrorCaptureRegister() might do the job but is not available for PSoC5LP.

How can I detect the situation after a shorting of the bus lines to automatically recover?

Thanks for input!

0 Likes
1 Solution
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi GuNo_288966​,

When the CAN_H and CAN_L is shorted, it will cause the node to enter the bus off state. When the node enters the bus off state, it triggers the BusOff interrupt if enabled in the configurator.

You can register CAN_BusOffIsr_Callback() as the callback function for busoff condition and set a variable in the callback. If the variable is set, call CAN_Start() to recover the bus. If you use the default ISR for bus off, it will call CAN_Stop() (check CAN_BusOffIsr() in CAN_INT.c ).

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

2 Replies
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi GuNo_288966​,

When the CAN_H and CAN_L is shorted, it will cause the node to enter the bus off state. When the node enters the bus off state, it triggers the BusOff interrupt if enabled in the configurator.

You can register CAN_BusOffIsr_Callback() as the callback function for busoff condition and set a variable in the callback. If the variable is set, call CAN_Start() to recover the bus. If you use the default ISR for bus off, it will call CAN_Stop() (check CAN_BusOffIsr() in CAN_INT.c ).

Regards,

Bragadeesh

Regards,
Bragadeesh

Hi Bragadeesh,

thanks, that worked.

However, the function CAN_GetErrorState still replies 0 = normal operation when this problem occurs.

According to the CAN component documentation, the reply should be "1x" = bus off.

Regards,

Guenter

0 Likes