Hello NXP experts:
The too-chain is S32 DS V2.1, multi-link debugger.
The design is CAN_A bus-off state can be read from ESR.FLTCONF after after CAN_H and CANL being kept short-wired for at least 5s. Error frame can be observed from CANoe.
But the bus-off state is not confirmed, reason is from debugger view, ESR_FLTCONF value is always 0. as below:
unfortunately, only general registers is displayed in my debugger 'register' window.
So I copy value of ESR and ECR to a global variable, at the same time, try to read them for memory view.
Global variables value can match the result of memory view.
The global variable CanA_ErrStatusR = 0x2252, so ESR.FLTCONF should be 0x10.
but the code block if((0x10 == CAN_A.ESR.B.FLTCONF) ||(0x11 == CAN_A.ESR.B.FLTCONF)) is NOT executed.
part of the bus-off handling code is below:
CanA_ErrStatusR = (uint32_t)CAN_A.ESR.R;
CanA_ErrCountR = (uint32_t)CAN_A.ECR.R;
if((0x10 == CAN_A.ESR.B.FLTCONF) ||(0x11 == CAN_A.ESR.B.FLTCONF))
{
if(1 == CAN_A.ESR.B.BOFFINT) /*this line never be executed*/
{
bBusOffFlag_A = TRUE;
BusOffState_A = BUS_OFF_DETECTED;
BusOffDelayer_A = 0;
fastRecoveryCnt_A = 0;
}
}
And the CR.BOFFREC bit is set to 1 to disable the automatic bus-off recovery.
This setting succeeded and can be confirmed from the read-back global value --CanA_BOFFREC and memory view (addr 0xFFFC0004)
the initialization code is:
uint8_t i;
CAN_A.MCR.R = 0x5000003F; // Put in Freeze Mode & enable all 64 message buffers
// CAN_A.CR.R = 0x00DB0006; // Configure for 8MHz OSC, 500KHz bit time
CAN_A.CR.R = 0x00DB0046; // Configure for 8MHz OSC, 500KHz bit time; Automatic recovering from Bus Off state disabled
CanA_BOFFREC = CAN_A.CR.B.BOFFREC;
Even in user manual , the FLTCONF is bit26-bit27, but the reading sequence is from left to right, because bit0~bit13 should ALWAYS be 0, if ESR = 0x2252, the correct value mapping is below:
Same solution works well in another product based on MPC5746R.
Thanks and BR
Zhou YiChuan
Hi,
FLTCONF is 2 bits wide field so you should not have
if((0x10 == CAN_A.ESR.B.FLTCONF) ||(0x11 == CAN_A.ESR.B.FLTCONF))
but rather
if((0b10 == CAN_A.ESR.B.FLTCONF) ||(0b11 == CAN_A.ESR.B.FLTCONF)) or
if((0x2 == CAN_A.ESR.B.FLTCONF) ||(0x3 == CAN_A.ESR.B.FLTCONF))
BR, Petr
hello Petr:
You'r correct, sorry for my wrong code. But now the issue is:
The ESR.FLTCONF is 1(== error passive), Bus-Off error was NOT created.
Even the CAN_H and CAN_L is short wired for at least 10s, and error frame is observed in CANoe,
Could you please tell me what register initialization was forgot?
Automatic bus-off recovering is disabled by setting CR.BOFFREC with following code:
CAN_A.CR.R = 0x00DB0046;
It can be confirmed from the memory view (addr 0xFFC00004) below:
And from the memory view of FlexCAN registers, the ECR is 0x0085, so TXECNT is still 0x85, not the condition for bus-off mode.
When I remove the CAN_H/L short wired, the transmission recovered automatically.
It seems the automatic bus-off recovery is not disabled,
PS: another snapshot for your information:
thanks and BR
Zhou YiChuan
Hi,
did you send message from MPC5742A with CANH/CANL shorted (or e.g. CANH grounded)?
BR, Petr
Hi, Petr:
Yes, 4 IDs of messages is sending from MPC5642A CAN_A cyclically. like below:
The SW is running on another 5642A ECU, same result is observed.
The CAN_A.ESR.FLTCONF bit is 1 while CAN_H/L being kept short-wired.
thanks and BR
Zhou YiChuan
Hi,
could you please share project you have, so I can check it.
Also share measurement of TX/RX/bus lines on MCU running given code.
BR, Petr
Hi,
sorry for a delay, unfortunately I havent got a board and later has no time.
Now I tested it on MPC5642A EVB board.
Starting your code, without CAN_A connected to the bus I see ACK error with error passive state but it does not go to CAN_A_AckErrorTask(). But seems it is not called by code at all. Adding below code
it can stop on testing ACK flag
Connecting board to PCAN tool I see message transmitted by board.
Shorting CANH/CANL it pass BOFFINT flag testing
So seems it is working as expected. Not sure of you further code, I did not get the meaning. Looks you do some reinit, etc. But there is no flag clearing. With BOFFREC set you need to clear it once you enter bus off state so you can leave it. This is how manual recovery works.
BR, Petr
connecting CAN_A with PCAN tool.