Reset CAN | Bus Silence

cancel
Showing results for 
Search instead for 
Did you mean: 

Reset CAN | Bus Silence

377 Views
felix_boeckmann
Contributor II

Hello,

i have build a project which has a CAN Communication.

I control this with CANoe and it works fine. But when I stop the CANoe simulation and restart it, the Evalboard don't send or recieve messages anymore. I have to reset it by shut off the supply voltage.

Maybe there is an Error or something because there is no BUS client anymore?! How can I reset it or deactivate it?

Thanks and Greetings,

Felix

0 Kudos
5 Replies

346 Views
mariuslucianand
NXP Employee
NXP Employee

Gentlemen,

I am not an expert in CAN, so I will ask one of my colleagues to respond to your question.

However, the C code is generated on top of the S32K SDK for Arm. Currently, I don't see any API function that resets the CAN module. 

A starting point will be to use the FLEXCAN_DRV_GetErrorStatus driver function, which returns the ESR1 register value. By having a look at this register, you can know in your code, when the Bus becomes IDLE. We don't have a block for that, but you can declare a Data Store Memory of uint32 and insert a custom code, to periodically call this function.

The only idea I have right now is to try to deinit and reinit the CAN module when the bus becomes IDE. I don't know if this is the right way, and I think there should be a more elegant way of solving this scenario. I will ask other engineers and we will reply here.

mariuslucianand_0-1606831590514.png

Regards,

Marius

 

 

 

0 Kudos

99 Views
Mayuresh10
Contributor I

Hello @mariuslucianand I tried running the flexcan_master_xfer_status_s32k11x.zip code it works perfectly fine when I run this code, but when I import the same data store memory block and system output block with the custom code given here in some other CAN program it doesn't work. Am I missing something here or are there any additional Simulink settings that needs to done? 

 

0 Kudos

333 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @felix_boeckmann@miguelallende,

Let's try a workaround to see if on your side this fixes the problem and you can continue the CAN communication after the CAN bus is reconnected.

So, we will insert a custom code that will return the ESR1 status register. If there is an TX Error we will abort the current transfer.

CAN_Status = FLEXCAN_DRV_GetErrorStatus(CAN_INSTANCE) ; 
if (CAN_Status & (1 << 9))
{
FLEXCAN_DRV_AbortTransfer(CAN_INSTANCE, MSG_BUFFER);
}

In the custom code you have to Change the CAN_INSTANCE with the instance that you are using (simply 0 or 1) and the MSG_BUFFER with the buffer that you are using (e.g. 15).

I have attached an example. Is for S32K116 but the same C code should work for your S32K144.

Let's give this a try.

Hope this helps,

Marius

 

0 Kudos

365 Views
miguelallende
Contributor I

Hi Felix.

I have the same problem reported days ago.

https://community.nxp.com/t5/NXP-Model-Based-Design-Tools/CAN-recovery-MPC5744P/m-p/1187572#M5387

Let's see if NXP give us a solution.

BR,

Miguel.

0 Kudos

45 Views
Anderson64
Contributor I

I am also encountering this issue. Don't know why its happening!!

The rules for increasing and decreasing the error counters are somewhat complex, but the principle is simple: transmit errors give 8 error points, and receive errors give 1 error point. Correctly transmitted and/or received messages causes the counter(s) to decrease.
Example (slightly simplified): Let’s assume that node A on a bus has a bad day. Whenever A tries to transmit a message, it fails (for whatever reason). Each time this happens, it increases its Transmit Error Counter by 8 and transmits an Active Error Flag. Then it will attempt to retransmit the message and the same thing happens.

Tags (1)
0 Kudos