MPC5748G receive extended ID and standard ID at the same mb

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

MPC5748G receive extended ID and standard ID at the same mb

1,695 Views
crackerzx
Contributor I

My OS is freertos,and components version is S32_SDK_C55

before I receive can data ,I must config first,but I don't know what kind frame I will receive(extended ID and standard ID) 

Now I can only receive 1 kind frame in the same MB.

What's the solution about this?

flexcan_data_info_t dataInfo =
{
.data_length = len,
.msg_id_type = FLEXCAN_MSG_ID_STD,
.enable_brs = false,
.fd_enable = false,
.fd_padding = 0U
};

/* Configure RX message buffer with index RX_MSG_ID and RX_MAILBOX*/
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, mailbox, &dataInfo, msgid);

Labels (1)
0 Kudos
3 Replies

1,521 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

If the CAN_CTRL2[EACEN] bit is negated, the IDE bit of Mailbox is always compared with the IDE bit
of the incoming frame, thus to receive both standard and externed IDs you need at least 2 MBs configured for the receiving.

You can try to set the CAN_CTRL2[EACEN] bit, then bit 30 of the masking register specify if IDE bit is don't care or not.

pastedImage_2.png

If you clear the rest of mask register bits (MG[28:0]) then the received ID is don't care too and all messages should be received into single prepared MB.

BR, Petr

1,312 Views
pmrlcbtcphtzjdq
Contributor III

thanks for the suggestions - it worked for me.
I was planning to use only one MB. This is how I set it up:

main.c

/* Initialize FlexCAN driver */
        if ( FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0) == 0)
        {
        	//enter freeze mode to set registers to accept extended ID
        	CAN_Type * const g_flexcanBase[] = CAN_BASE_PTRS;
        	CAN_Type * base = g_flexcanBase[INST_CANCOM1];
        	FLEXCAN_EnterFreezeMode(base);
              // set the EACEN bit to enable mask on MB[IDE]
              CAN_0->CTRL2 |= CAN_CTRL2_EACEN(1);
        	FLEXCAN_ExitFreezeMode(base);
    }

and in a task:

uint8_t rx_mailbox = 1;

    // Set information about the hdata to be received
    flexcan_data_info_t dataInfo =
    {
            .data_length = 1U, //don't care - larger msgs are also received
            .msg_id_type = FLEXCAN_MSG_ID_EXT, 
            .enable_brs  = false,
            .fd_enable   = false,
            .fd_padding  = 0U
    };
    // Configure RX message buffer with index RX_MSG_ID and RX_MAILBOX
    FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, rx_mailbox, &dataInfo, 1);

    // set the Mask to receive all the messages
    FLEXCAN_DRV_SetRxMbGlobalMask(INST_CANCOM1, FLEXCAN_MSG_ID_EXT, 0);

while(1){
        status_t  CANReceiveStatus;

        // Define receive buffer
        flexcan_msgbuff_t recvBuff;

        // Start receiving data in RX_MAILBOX.
        CANReceiveStatus = FLEXCAN_DRV_Receive(INST_CANCOM1, rx_mailbox, &recvBuff);
      .
      .
      .
}
Tags (1)
0 Kudos

1,521 Views
crackerzx
Contributor I

Thank you very much,I will try this solution.

BR,

mian

0 Kudos