CAN Re-connection on Bus-off/Disconnection

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAN Re-connection on Bus-off/Disconnection

3,026 Views
Abina
Contributor I

Hi Team,

When I attempt to use the FlexCAN on the S32K146, I am having trouble recovering the CAN bus if the CAN bus is temporarily or physically disconnected and then reconnecting.

The issues are

  1. If the CAN is disconnected, the BOFFINT bit (3rdbit of ESR1 value) is not set.
  2. After reconnecting, data is not transferring from CAN TX.
    In code:

During initialization, I enabled and set the priority for the CAN1_ORed_0_15_MB_IRQn interrupt and used the FLEXCAN_DRV_InstallErrorCallback function to check the bus off status. The error callback function collects the error status data (the ESR1 value by the FLEXCAN_DRV_GetErrorStatus (INST_CANCOM1) function), and using CAN_ESR1_BOFFINT_MASK, I collect the BOFFINT bit value. If the bit is set, the CAN bus is aborted using FLEXCAN_DRV_AbortTransfer (INST_CANCOM1, 0).

can_init.png

error_cb.png

I implemented the code as mentioned above after searching and gathering data from the NXP community, but the aforementioned issue is still there.

While debugging the error callback, tried to toggle the GPIO pin inside the error callback to validate the CAN error detection as continuous monitoring for reconnection. Found that the callback only called for some milliseconds for the error that occurred in the CAN bus; the callback function did not continuously call; it seems it stuck.

can_pico.png

Any idea why this is happening and how to solve it?

 

@ArunkumarV  FYR

Thanks

0 Kudos
Reply
4 Replies

3,010 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

1) Bus off is entered when module is transmitting message and detect error (other then ACK), in this case TXERROR counter is increasing and after it is >255 bus off is entered. If you just disconnect bus, but have transceiver terminated, you cannot enter to Bus off. You can try to short bus, or do CANH-GND or CANL-VDD connection while message is transmitted.

2) not sure how do you transmit message, but your error callback aborts the TX MB for each error detected. Consider if this is need

BR, Petr

0 Kudos
Reply

2,962 Views
Abina
Contributor I

Hi,

Please respond and assist me in resolving the problem, which is to assist in fulfilling the client's requirement .

Thanks in advance. Please provide your support.

Best

Abina

0 Kudos
Reply

3,006 Views
Abina
Contributor I

Hi

Thanks for your quick response.

I am trying to solve an issue, so I am trying to understand the CAN operations with different methods.

The issue is, when a device connection disconnected physically and connect back to the CAN communication.

Is it possible to recover the CAN communication and transfer the data again? Do we need any Reinit of CAN?

How to achieve this in S32K1xx controller?

Kindly share some inputs or steps or sample code.

Thanks in advance. Please provide your support to solve this issue.

Best

Abina

0 Kudos
Reply

2,949 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

after reconnection, no module reinit is needed. Module should synchronize to the bus again. Maybe you can see some errors detected. You should be able to send messages again.
If have issue you can inspect FlexCAN registers to know status. Check MCR, ECR,ESR1 registers and content of TX MBs.

BR, Petr

0 Kudos
Reply