Flexcan Receive without filtering

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

Flexcan Receive without filtering

ソリューションへジャンプ
1,333件の閲覧回数
Alex19
Contributor II

Hello NXP Community,

 

I use S32K144 board, and i need to receive can messages without filtering and send the data with UART I found in other topics, how to realise this.  

 

uint16_t MSG_ID = 0x07FF;

/*Initialize the FlexCAN module */

 FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);

 

/* Enable message buffer global masking */

FLEXCAN_DRV_SetRxMaskType(INST_CANCOM1, FLEXCAN_RX_MASK_GLOBAL);

/* Set the global mask as "don't care" for each message buffer */
FLEXCAN_DRV_SetRxMbGlobalMask(INST_CANCOM1, FLEXCAN_MSG_ID_STD, 0U);

 

flexcan_data_info_t dataInfo =
{
.data_length = 8U,
.msg_id_type = FLEXCAN_MSG_ID_STD,
.enable_brs = false,
.fd_enable = false,

.fd_padding = 0U
};

 

/* Configure message buffer 0 for reception */

FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 0U, &dataInfo, MSG_ID);

 

/* Start receiving data in message buffer 0 */

while (1)

{

if (FLEXCAN_DRV_Receive(INST_CANCOM1, 0U, &recvBuff) == STATUS_SUCCESS)

{

send with UART;

}

 

So it works. I receive for example 7 CAN messages with ID 0x010,0x011, 0x012, 0x013, 0x014, 0x015, 0x016.  But I have a question, why I receive 0x012, 0x012, 0x010 etc. I mean I receive several time the same ID. Or I receive for example 0x013, 0x013,0x015, 0x013, 0x013 etc 

0 件の賞賛
返信
1 解決策
1,325件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

when using non-blocking function, you should check if transfer is completed, so you can have below code

while(1)
{
     FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX, &recvBuff);
     /* Wait for the message to be received */
     while (FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MAILBOX) == STATUS_BUSY);

     send with UART
}

 

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,326件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

when using non-blocking function, you should check if transfer is completed, so you can have below code

while(1)
{
     FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX, &recvBuff);
     /* Wait for the message to be received */
     while (FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MAILBOX) == STATUS_BUSY);

     send with UART
}

 

0 件の賞賛
返信
1,303件の閲覧回数
Alex19
Contributor II

Helllo, 

 

Yes it works, thank you very much

0 件の賞賛
返信