Flexcan Receive without filtering

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

Flexcan Receive without filtering

Jump to solution
1,036 Views
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 Kudos
1 Solution
1,028 Views
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
}

 

View solution in original post

0 Kudos
2 Replies
1,029 Views
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 Kudos
1,006 Views
Alex19
Contributor II

Helllo, 

 

Yes it works, thank you very much

0 Kudos