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,
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.
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))
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,
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.