FlexCAN Receive question on S32K148

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

FlexCAN Receive question on S32K148

1,836件の閲覧回数
sumityadav
Contributor II

In my application I would like to configure FlexCAN to receive a message with a specific ID. I understand that I need to setup a mailbox to receive the message using FLEXCAN_DRV_ConfigRxMb followed by FLEXCAN_DRV FLEXCAN_DRV_Receive.

My question is the following:

When this message is received and the callback is invoked can I safely call both of these functions again to configure the mailbox to receive the same message ID again from within the callback? I need this to happen as fast as possible so as to no drop messages. If there is a better way of handling this please let me know.

Thanks!

0 件の賞賛
5 返答(返信)

1,442件の閲覧回数
alexandrunan
NXP Employee
NXP Employee

Hello,

If you want to be sure you don't lost messages between MBs config, you can use RxFIFO if you don't use CAN FD messages. To do that you need to set RxFIFO filters.

flexcan_id_table_t flTable[8];

for(i=0;i<8;i++)
{
flTable[i].id = 2;
flTable[i].isExtendedFrame=false;
flTable[i].isRemoteFrame=false;
}

FLEXCAN_DRV_ConfigRxFifo(INST_CANCOM1,FLEXCAN_RX_FIFO_ID_FORMAT_A,&flTable[0]);

/* You can set a filter mask or not for acceptance by setting global mask to be more easy to handle or you can

skip this part and will check all the id filters as set by initialization */

/* This will set mask to 3 and check ID type as filter set */

FLEXCAN_DRV_SetRxFifoGlobalMask(INST_CANCOM1, FLEXCAN_MSG_ID_STD, ((1U<<30U)|0x3));
/* Sets the Rx masking type as rx global mask */
(void) FLEXCAN_DRV_SetRxMaskType(INST_CANCOM1, FLEXCAN_RX_MASK_GLOBAL);

/* End of filter acceptance masking */

 Call for transfer of a message already in fifo. For every message in fifo you need to call again the function. If you have a callback installed you can call it again in the event triggered is FLEXCAN_EVENT_RXFIFO_COMPLETE.

status = FLEXCAN_DRV_RxFifo(INST_CANCOM1, &recvBuff);

or you can poll the MBs status for RxFIFO which is MBs 0 all the time.

while(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, 0U) == STATUS_BUSY);

BR,

Alexandru Nan

0 件の賞賛

1,442件の閲覧回数
sumityadav
Contributor II

Hi Alexandru,

Any suggestions on this?

Thanks,

Sumit

0 件の賞賛

1,442件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi Sumit,

I think you can safely call FLEXCAN_DRV_Receive within callback function in FLEXCAN_EVENT_RX_COMPLETE event. You do not call FLEXCAN_DRV_ConfigRxMb again.

FLEXCAN_DRV_Receive just enable MB interrupt which was disabled within IRQ handler before callback is called.

BR, Petr

0 件の賞賛

1,442件の閲覧回数
sumityadav
Contributor II

Thanks you Petr! Appreciate the response.

0 件の賞賛

1,442件の閲覧回数
sumityadav
Contributor II

Thanks for the response Alexandru. We are using CAN FD hence RXFIFO is not an option. 

0 件の賞賛