Issue Receiving multiple ID frame on FlexCAN 1 of mxrt1051

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

Issue Receiving multiple ID frame on FlexCAN 1 of mxrt1051

923件の閲覧回数
Maheshkadam9922
Contributor II
 
 
we are working on flexcan1 , able to receive single id frame using flexcan1 , we did below setting 
we configure 10 number of MB
 
****************************************************************************************************
#define RX_MESSAGE_BUFFER_NUM (10)
#define TX_MESSAGE_BUFFER_NUM (9)
 
#define DLC (8)
#define BUF_SIZE (13)
****************************************************************************************************
flexcan_frame_t rxFrame;
volatile bool rxComplete = false;
 
uint8_t RX_BUF[BUF_SIZE];
****************************************************************************************************
/*
 * This part is the implementation of interrupt service routine, this is invoked when new data arrives
 * When the ISR is called it first checks the status of a flag indicating new data has arrived on RX_MESSAGE_BUFFER_NUM
 * If the flag is set, it clears the flag and then reads the data from message buffer into rxFrame
 * the rxComplete variable is set to indicate that the new message has been received
 * SDK_ISR_EXIT_BARRIER is called for exiting the ISR
 */
****************************************************************************************************
void CAN1_FLEXCAN_IRQHANDLER(void)
{
uint64_t flag = 1U;
 
/* If new data arrived. */
if (0U != FLEXCAN_GetMbStatusFlags(CAN1_PERIPHERAL, flag << RX_MESSAGE_BUFFER_NUM))
{
FLEXCAN_ClearMbStatusFlags(CAN1_PERIPHERAL, flag << RX_MESSAGE_BUFFER_NUM);
 
(void)FLEXCAN_ReadRxMb(CAN1_PERIPHERAL, RX_MESSAGE_BUFFER_NUM, &rxFrame);
 
rxComplete = true;
}
SDK_ISR_EXIT_BARRIER;
}
 
****************************************************************************************************
int main(void)
{
uint64_t flag = 1U;
 
BOARD_ConfigMPU();
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
 
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
/* Init FSL debug console. */
BOARD_InitDebugConsole();
#endif
***********************************************configuration API****************************************************
NVIC_SetPriority(CAN1_FLEXCAN_IRQN, CAN1_FLEXCAN_IRQ_PRIORITY);
 
EnableIRQ(CAN1_FLEXCAN_IRQN);
 
FLEXCAN_Init(CAN1_PERIPHERAL, &CAN1_config, CAN1_CLOCK_SOURCE);
 
/* Message buffer 0 initialization */
FLEXCAN_SetRxMbConfig(CAN1_PERIPHERAL, 10, &CAN1_rx_mb_config_0, true);
 
/* Enable Rx Message Buffer interrupt. */
FLEXCAN_EnableMbInterrupts(CAN1_PERIPHERAL, flag << RX_MESSAGE_BUFFER_NUM);
 
while(1)
{
if(rxComplete == true)
{
RX_BUF[0] = ((rxFrame.id>>2)  >> 24 & (0xFFU));
RX_BUF[1] = ((rxFrame.id>>2) >> 16 & (0xFFU));
RX_BUF[2] = (rxFrame.length & (0xFFU)) ;
RX_BUF[3] = (rxFrame.dataWord0 >> 24 & (0xFFU));
RX_BUF[4] = (rxFrame.dataWord0 >> 16  & (0xFFU));
RX_BUF[5] = (rxFrame.dataWord0 >> 8  & (0xFFU));
RX_BUF[6] = ((rxFrame.dataWord0 >> 0) & (0xFFU));
RX_BUF[7] = (rxFrame.dataWord1 >> 24 & (0xFFU));
RX_BUF[8] = ((rxFrame.dataWord1 >> 16) & (0xFFU));
RX_BUF[9] = ((rxFrame.dataWord1 >> & (0xFFU));
RX_BUF[10] = ((rxFrame.dataWord1 >> 0 ) & (0xFFU));
 
LPUART_WriteBlocking(LPUART1_PERIPHERAL,RX_BUF, sizeof(RX_BUF));
 
rxComplete = false;
}
}
}

 

 

above code work for single frame in our code we need to configure multiple ID for that we configure multiple Message buffer

/* Message buffer 0 initialization - 10 number of MB*/ 
FLEXCAN_SetRxMbConfig(CAN1_PERIPHERAL, 10, &CAN1_rx_mb_config_0, true);
 
/* Message buffer 1 initialization-11 number of MB */
FLEXCAN_SetRxMbConfig(CAN1_PERIPHERAL, 11, &CAN1_rx_mb_config_1, true);
 
/* Message buffer 2 initialization-12 number of MB */
FLEXCAN_SetRxMbConfig(CAN1_PERIPHERAL, 12, &CAN1_rx_mb_config_2, true);
 
also enable rx msg buffer interrupt IMASK register
/* Enable Rx Message Buffer interrupt for 10 number of MB. */
FLEXCAN_EnableMbInterrupts(CAN1_PERIPHERAL, flag << 10);
 
/* Enable Rx Message Buffer interrupt.for 11 number of MB. */
FLEXCAN_EnableMbInterrupts(CAN1_PERIPHERAL, flag << 11);
 
/* Enable Rx Message Buffer interrupt.for 12 number of MB. */
FLEXCAN_EnableMbInterrupts(CAN1_PERIPHERAL, flag << 12);
 
here we use different MB for different ID  but not able to receive multiple frame ,please assist how multiple ID frame receive ? Is there any SDK example code of Flexcan1 for multiple ID 
0 件の賞賛
返信
1 返信

903件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Maheshkadam9922 ,

  I suggest you set the MASK register to receive all ID, then it will don't have filter.

  Eg. FLEXCAN_SetRxMbGlobalMask(EXAMPLE_CAN, 0x00);

  Please try it.

  If you still have issues, please use your company email to create the question post, then you will have higher support priority than the 3rd part email.

 

Wish it helps you!

Best Regards,

Kerry

0 件の賞賛
返信