flexcan demo in SDK2.0

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

flexcan demo in SDK2.0

1,881 Views
dsytj88
Contributor II

Hi

basing on flexcan demo in sdk2.0,I change a little for the main function,that's:

in while() function,send some message directly in CAN0 channel.

the ECU is only connected to CANOE, first,run CANOE for trace measurement,

then stop the CANOE for a while,then restart CANOE, CANOE can't acquire CAN message sending from CAN0.

I think after diconnected, ECU becomes to single node ,and transciver disable the message sending,

how to keep the ECU transmitting in single node mode? 

thank you

br

yu

0 Kudos
Reply
7 Replies

1,746 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

generally, if you have single node on the bus and it is transmitting a message then it is not acknowledged and a node is re-transmitting a message still. FlexCAN should enter error passive mode, transmit message still until it is ACKed again.

If not you should check FlexCAN ESR1, ECR register to know what state you have and what errors are detected.

BR, Petr

0 Kudos
Reply

1,746 Views
dsytj88
Contributor II

hi

ECR.PNGESR1.PNG

hi

this is the register status for ECR and ESR1.and FlexCAN is in error passive mode.but after CANOE is restarted again, normally FlexCAN could get ACK and the message sending should be successfull,but in CANoe TRACE window,there is no message acquired,until the module reset(powerdown and power on again). 

0 Kudos
Reply

1,746 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

as you wrote, FlexCAN could not get ACK from CAN tool, did you check CAN bus with scope?. Seems this is due to CAN tool. Maybe bit timing?

BR, Petr

0 Kudos
Reply

1,746 Views
dsytj88
Contributor II

hi

for CAN transmiting issue in single node mode,I see the ACK is greater than 96 and then flexcan module goes into passive mode,now i enable the tx warning interrupt,and it could trigger the interrupt,in the ISR function,I try to clear the tx error counter,the scripts as belows:

if(((base->ESR1)&ACKErrMsk)!= 0)
    {

     FLEXCAN_EnterFreezeMode(base);

  base->MCR = ((base->MCR & (~CAN_MCR_FRZ_MASK)) | CAN_MCR_FRZ(1));
  base->MCR = ((base->MCR & (~CAN_MCR_HALT_MASK)) | CAN_MCR_HALT(1));
  while (0 == (base->MCR & 0b1000000000000000000000000)); // ensure entering into freeze mode
  base->ECR &= ~(0xFF);
  base->MCR = ((base->MCR & (~CAN_MCR_FRZ_MASK)) | CAN_MCR_FRZ(0));
  base->MCR = ((base->MCR & (~CAN_MCR_HALT_MASK)) | CAN_MCR_HALT(0));
  FLEXCAN_ExitFreezeMode(base);}

 FLEXCAN_ClearErrIntStatusFlag(base);
    return;

but after programming the code,the error counter is not greater than 96 even in single node mode,

but it's strange that the message is not able to transmit to tester from controller,do you have any idea?

Thank you.

Best regards

0 Kudos
Reply

1,746 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

I quickly tried flexcan_mpc5748g example from SDK300 on DEVKIT-MPC5748G board connected to PCAN tool.

Upon button press the message is send and if PCAN is conencted I see message received within it. Once I disconnect PCAN and press board's button, message becomes transmitted still due to missing ACK. TXERROR counter is 0x80, module is in error passive state. Once I connect PCAN again, message is transmitted successfully and TXERROR counter decrease by 1.

So I see expected behavior as I wrote for first time.

If you clear error counter in freeze mode and error flag too and have still single node on the bus, the node becomes error passive again as message is still transmitted and not ACKed.

BR, Petr

0 Kudos
Reply

1,746 Views
dsytj88
Contributor II

hi

if it's the tool issue,I think it's not ok after reset the controller.

can you hava a try using the flexcan demo in SDK2.0?

thank you

0 Kudos
Reply

1,746 Views
dsytj88
Contributor II

for MPC5748G application

0 Kudos
Reply