MPC5604 - is there any sample code available for FlexCAN Listen Only Mode to receive CAN Frames

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

MPC5604 - is there any sample code available for FlexCAN Listen Only Mode to receive CAN Frames

1,596 Views
naveenlingampel
Contributor I

does CAN Receive interrupt works in LOM mode also?

Labels (1)
5 Replies

1,380 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

If LOM bit is asserted in Freeze mode, the FlexCAN module enters Listen-Only Mode.

Transmission is disabled, all error counters are frozen and the module operates in a CAN Error Passive mode. Only messages acknowledged by another CAN station will be received. If FlexCAN detects a message that has not been acknowledged, it will flag a BIT0 error, as if it was trying to acknowledge the message. RX interrupts are functional in LOM mode normally.

 

Attached if simple example I did for TRK-MPC5606B. CAN0 is used to send message, CAN1 to receive it with a help of RXFIFO.

I have added CAN2 to work in LOM mode to receive all standard ID to MB0 and extended IDs to MB1. Interrupt is enabled.

BR, Petr

1,313 Views
tongxiaohui
Contributor I

Hi,Peter:I transplant the 5606B code you offered to MPC5604B and it works well,Buff[9] for Tx and Buff[5] for Rx function with the same CAN0 channel.Then I adjust the Buff[6] to Buff[5],unfortunately,The Rx does not work.

(1)Buff[6] and Buff[5] shares the same interrupt vector ,No.69--Flexcan_Buff_04_07

(2) CAN_0.IMRL.R = 0x00000040; // enable BUF06I interrupt

(3)if(CAN_0.IFRL.B.BUF06I)

{
/* upon receiving the interrupt flag */

/* check the ID field */
/* not really needed in this example */
/* useful in case when multiple IDs are received
* by the FIFO (Rx mask feature) */
temp = CAN_0.BUF[6].ID.R;
//if(( 0x12340000 ) != temp)
//{
/* error ! trap here.
* we have configured this MB to receive
* just ID 0x12340000 and not another */
// while(1) {}
// }

rxlength = (uint8_t) CAN_0.BUF[6].CS.B.LENGTH;

/* read the received data */
for (j=0; j<rxlength; j++)
{
RxDATA[j] = CAN_0.BUF[6].DATA.B[j];
}

u8_rxdata=CAN_0.BUF[6].DATA.B[0];

temp = CAN_0.TIMER.R; /* Read TIMER to unlock message buffers */

                                                                //CAN_0.IFRL.R = 0x00000020; /* clear the BUF05I bit - bit 5 */
CAN_0.IFRL.R = 0x00000040;/* clear the BUF06I bit - bit 6 */

}

 

I am puzzled with it,can you offer me some help?

 

0 Kudos

1,380 Views
naveenlingampel
Contributor I

Thank you Petr Stancik.

Assuming that there are only two nodes. one configured in LOM mode and the other in Normal mode transmitting a periodic message.

since there are no other nodes to ACK the message transmitted by Normal mode, will the node in LOM mode will just flag a BIT0 error or will it flag a BIT0 error as well as receive the message in the configured MB.

I am yet to get my evaluation board to do this. will post again once i have the board.

Thanks for your input. 

0 Kudos

1,380 Views
PetrS
NXP TechSupport
NXP TechSupport

You will get just a Bit error. No message is received.

1,312 Views
tongxiaohui
Contributor I

Hi,Peter:I transplant the 5606B code you offered to MPC5604B and it works well,Buff[9] for Tx and Buff[5] for Rx function with the same CAN0 channel.Then I adjust the Buff[6] to Buff[5],unfortunately,The Rx does not work.

(1)Buff[6] and Buff[5] shares the same interrupt vector ,No.69--Flexcan_Buff_04_07

(2) CAN_0.IMRL.R = 0x00000040; // enable BUF06I interrupt

(3)if(CAN_0.IFRL.B.BUF06I)

{
/* upon receiving the interrupt flag */

/* check the ID field */
/* not really needed in this example */
/* useful in case when multiple IDs are received
* by the FIFO (Rx mask feature) */
temp = CAN_0.BUF[6].ID.R;
//if(( 0x12340000 ) != temp)
//{
/* error ! trap here.
* we have configured this MB to receive
* just ID 0x12340000 and not another */
// while(1) {}
// }

rxlength = (uint8_t) CAN_0.BUF[6].CS.B.LENGTH;

/* read the received data */
for (j=0; j<rxlength; j++)
{
RxDATA[j] = CAN_0.BUF[6].DATA.B[j];
}

u8_rxdata=CAN_0.BUF[6].DATA.B[0];

temp = CAN_0.TIMER.R; /* Read TIMER to unlock message buffers */

                                                                //CAN_0.IFRL.R = 0x00000020; /* clear the BUF05I bit - bit 5 */
CAN_0.IFRL.R = 0x00000040;/* clear the BUF06I bit - bit 6 */

}

 

I am puzzled with it,can you offer me some help?

 

Tags (1)
0 Kudos