K146 CAN0 BUSOFF issue

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

K146 CAN0 BUSOFF issue

3,004 Views
Ali22
Contributor III

Dears,

Anyone who meet this issue: When repeatedly trigger CAN0 bus-off for several times, it happened like this: ESR1[FLTCONF] = 0x3, but ESR1[BOFFINT] is never set, CTRL1[BOFFMSK])  always is set. We handle the bus-off error interrupt like this:if ESR1[BOFFINT] = 1, we will re-initialize the CAN0 module , The question is, in theory , bus-off happen -> ESR1[FLTCONF] = 0x3  ---------------> ESR1[BOFFINT]=1  ->CAN0 re-initialize ->bus-off happen-> ESR1[FLTCONF] = 0x3~~~~~~~~~this loop can Keep going, but now this loop is stopped for unknown reason, who meet this issue and how to fix it? 

1.jpg

Tags (1)
0 Kudos
Reply
7 Replies

2,969 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Ali22

We have analyzed and discussed your problem before.

This should be a problem caused by the order of clearing the ESR1 register:

I can easily reproduce this working condition.

I wrote a test demo that you can use directly to observe, and I recorded a video for your reference


a. S32K146EVB
b. S32 Design Studio for Arm V2.2 + RTM 3.0.x

1. Run the attached project, which will send CAN frames regularly
2. Short CAN_H and CAN_L to simulate bus-off events
3. Enter flexcan0_ErrorCallback();
4. flexcan0_ErrorCallback() will reinitialize the flexcan module, and all flexcan registers will be reset
5. Try to send (continue to short CAN_H and CAN_L at this time)
6. The program will enter CAN0_Error_IRQHandler()->FLEXCAN_ClearErrIntStatusFlag(), where the ESR1 register will be cleared

7.For now, you will see the ESR1.BOFFINT = 0 but FLTCONF = 0x03.

The program will not into flexcan0_ErrorCallback() anymore.

 

0 Kudos
Reply

2,961 Views
Ali22
Contributor III

Dears

Thanks for your support, but we encounter the issue is we just set a flag in flexcan0_ErrorCallback();and flexcan module re-initialize is put in freertos 10ms task, in theory, freertos interrupt can' t break CAN0 error interrupt.

1.jpg

so re-initialize flexcan module will never happen before CAN0_Error_IRQHandler() in the below steps, all right?

 

1. Run the attached project, which will send CAN frames regularly
2. Short CAN_H and CAN_L to simulate bus-off events
3. Enter flexcan0_ErrorCallback();
4. flexcan0_ErrorCallback() will reinitialize the flexcan module, and all flexcan registers will be reset
5. Try to send (continue to short CAN_H and CAN_L at this time)
6. The program will enter CAN0_Error_IRQHandler()->FLEXCAN_ClearErrIntStatusFlag(), where the ESR1 register will be cleared

7.For now, you will see the ESR1.BOFFINT = 0 but FLTCONF = 0x03.

0 Kudos
Reply

2,958 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Ali22

"so re-initialize flexcan module will never happen before CAN0_Error_IRQHandler() in the below steps, all right?"

You understand it wrong.
As long as your flexcan is still sending messages between reinitializing flexcan and clearing the ESR1 register, this problem may occur.

Solution 1.
1. Disable FLEXCAN_ClearErrIntStatusFlag() and test your project to see if this phenomenon still occurs.

Solution 2.

2.After entering CAN0_Error_IRQHandler(), turn on BOFFREC = 0, bus-off automatic recovery instead of reinitialization, and confirm the bus-off status by polling the FLTCONF bit

 

 

0 Kudos
Reply

2,923 Views
Ali22
Contributor III

Thank you, I will try the 2 solutions.

 I want let my discribtion more clear, I want express, when  bus-off happen the interrupt process(left)  can't be inserted by freertos task event process (right), right?

Simply to say, between the bus-off event interrupt process(step3-step7), can0 module can't be re-initialized?

Because CAN0 interrput priority is higher than freertos.

1.jpg

0 Kudos
Reply

2,913 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Ali22

Your diagram is wrong. Even if you initialize FlexCAN immediately after the "bus-off event happened agian", there will be no problem.

The problem is that no new bus-off event can occur between the completion of reinitialization of FlexCan and the clearing of the ESR1 register.

So how does a new bus-off event occur?

That is, the external factors that caused the bus-off were not removed. At this time, FlexCan tried to send a message, which would generate a new bus-off event.

 

你的图不对,就算是在“bus-off event happed agian”之后立马初始化FlexCAN,也不会有问题。

问题是在重新初始化FlexCan完成之后至清除ESR1寄存器之间不能发生新的bus-off事件。

那么新的bus-off事件是如何发生的?

即造成bus-off的外部因素没有移除,此时FlexCan尝试发送了报文,这就会产生新的bus-off事件。

0 Kudos
Reply

2,900 Views
Ali22
Contributor III

Dears

Yes, it is not correct, thanks for your mentioned, it should like this:

1.jpg

What I want to know is that in this software architecture, CAN0 initialization cannot occur between Enter flexcan0_Errocall() and Enter CAN0_Errc_IRQHandler(), right?
Because the task of CAN0 is executed in freeRTOS, it is impossible to interrupt the execution process of CAN0 Error interrupt.

我想了解的是在这种软件架构下CAN0初始化不可能发生在Enter flexcan0_ErrorCallback() 和 Enter CAN0_Error_IRQHandler()之间吧?

因为CAN0的任务是执行在freeRTOS里的,不可能打断CAN0 Error中断执行过程。

Tags (1)
0 Kudos
Reply

2,893 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Ali22

I'm not sure, and we don't support FreeRTOS applications. This is not within our support scope.

We have discussed this for so long, I just want to tell you the possible causes of this situation and how to simulate this situation.

You can set some flags or logs in the program to locate the specific cause of the problem.

我不确定,我们也不去支持FreeRtos的应用,这不在我们的支持范围。

我们讨论这么久,我只是想告诉你造成这个状况的可能原因以及如何去模拟这种状况的发生。

你们可以自己在程序里面去设置一些标志位或者log来定位具体的问题原因。

0 Kudos
Reply