Questions about CAN state

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

Questions about CAN state

1,668 Views
jm_shin
Contributor I

Hello

When we successfully received the CAN message, we checked that 'mbs [mb_idx] .state' was set to 'FLEXCAN_MB_IDLE' in 'FLEXCAN_DRV_GetTransferStatus'.

However, there is a problem when receiving different CAN ID Messages.
'Mbs [mb_idx] .state' is set to 'FLEXCAN_MB_IDLE' regardless of the CAN ID when receiving the first CAN ID Message and receiving another CAN ID Message

To improve this, 'CAN_Init' is performed after 'CAN_Deinit', but mbs '[mb_idx] .state' is keep as 'FLEXCAN_MB_IDLE'.

ex)

while(CAN_GetTransferStatus(&can_pal1_instance, RX_BUFF_IDX) == STATUS_BUSY);

CAN_Deinit(&can_pal1_instance);
CAN_Init(&can_pal1_instance, &can_pal1_Config0);

while(CAN_GetTransferStatus(&can_pal1_instance, RX_BUFF_IDX_2) == STATUS_BUSY);

Could you please share the guide to resolve this issue

Thanks

Labels (1)
0 Kudos
Reply
5 Replies

1,410 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the driver works this way.

CAN_Receive(INST_CAN_PAL1, RX_MAILBOX, &recvMsg) is used to start receiving data in RX_MAILBOX. After successful receive "recvMsg" is updated with receive data and driver's structure 'mbs [mb_idx] .state' is set to 'FLEXCAN_MB_IDLE'.

To allow another receive into RX_MAILBOX you need to call CAN_Receive(INST_CAN_PAL1, RX_MAILBOX, &recvMsg) again after while(CAN_GetTransferStatus(&can_pal1_instance, RX_BUFF_IDX) == STATUS_BUSY); passes.

BR, Petr

0 Kudos
Reply

1,410 Views
jm_shin
Contributor I

Dear Petr Stancik

Thank you for answer.

CAN_Receive could be called again to receive another message on RX_MAILBOX.

I would like to receive various Msg IDs.
However, in the example, only one Msg ID is set, and only the declared Msg ID is waiting for reception.
How do I receive various Msg IDs?
Do I need to set up multiple RX_MALEBOX? Or can I set various Msg IDs in 'CAN_ConfigRxBuff', 'CAN_Receives'?

Thanks

0 Kudos
Reply

1,410 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

either you will prepare more MBs for individual IDs or will set mask register to accept ID range or all IDs into single MB, as was e.g. discussed here https://community.nxp.com/message/1059503

BR, Petr

0 Kudos
Reply

1,410 Views
jm_shin
Contributor I

Dear Petr Stancik

Could you please explain 'FLEXCAN_DRV_SetRxIndividualMask' function?

I expected to receive CAN msg of all IDs, but olny ID set in 'FLEXCAN_DRV_ConfigRxMb' wiil be received.

The test code is shown below.

=================================================

FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MAILBOX_1, &dataInfo, 0x100); //RX_MAILBOX_1 = 1UL
 FLEXCAN_DRV_SetRxIndividualMask(INST_CANCOM1,FLEXCAN_MSG_ID_STD,RX_MAILBOX_1,0xFFFFFFFFu);
 FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX_1, &recvBuff);

 for(;;)
 {
  if(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MAILBOX_1) == STATUS_SUCCESS)
  {
   FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX_1, &recvBuff);
   count ++;
  }
 }

=================================================

Please correct me if I misunderstood your answer.

Thanks

0 Kudos
Reply

1,410 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you received single ID only as you did not clear Mask register, also be sure if individual or global masking scheme is used. See more in below post

https://community.nxp.com/message/940289?commentID=940289#comment-940289

BR, Petr 

0 Kudos
Reply