Can process multi msg id

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

Can process multi msg id

1,148 Views
jay_zhang
Contributor II

Hi NXP dev team,

I check the can example code to receive/send can data using below code with SDK:

FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MAILBOX0, &dataInfo0, RX_MB_ID0);

FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX1, &recvBuff1);

The code works on our board, but in our user scenario we have 3 can id(0x7df, 0x7e0, 0x7e8) to listen, I don't know how to filter the expected can id.

Please help to advice.

Thanks

Jay

Tags (3)
0 Kudos
Reply
3 Replies

1,023 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Jay,

simply configure more RX MBs for dedicated ID in similar manner you outlined.

Also if not enabling CAN FD you can use RX FIFO for message receiving and you define list of ID to be received in the RX FIFO ID table.

BR, Petr

0 Kudos
Reply

1,023 Views
jay_zhang
Contributor II

Hi Stancik,

Thanks for your reply, is there any demo for this or do you have sample code to share?

Jay

0 Kudos
Reply

1,023 Views
PetrS
NXP TechSupport
NXP TechSupport

you can try to modify example code to have

FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MAILBOX0, &dataInfo0, RX_MB_ID0);

FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MAILBOX1, &dataInfo1, RX_MB_ID1);

FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MAILBOX2, &dataInfo2, RX_MB_ID2);

FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX0, &recvBuff0);

FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX1, &recvBuff1);

FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX2, &recvBuff2);

while(1)

{

      if(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MAILBOX0) == STATUS_SUCCESS)

      {

            /* process recvBuff0 as needed */

            ....

            /* Start receiving data in RX_MAILBOX0 again. */
            FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX0, &recvBuff0);

      }

      if(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MAILBOX1) == STATUS_SUCCESS)

      {

            

            /* process recvBuff1 as needed */

            ....

            /* Start receiving data in RX_MAILBOX1 again. */
            FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX1, &recvBuff1);

      }

      if(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MAILBOX2) == STATUS_SUCCESS)

      {

              

            /* process recvBuff2 as needed */

            ....

            /* Start receiving data in RX_MAILBOX2 again. */
            FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX2, &recvBuff2);

      }

}

BR, Petr

0 Kudos
Reply