NXP MPC-5748G Read and Transmit CAN messages

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

NXP MPC-5748G Read and Transmit CAN messages

Contributor I


I am having trouble writing an Rx method for receiving messages using a MPC-5748G. I am attempting to create a method which can be passed an ID argument and it writes the received message out to the serial port. I have my Tx method down using one mailbox but am having trouble receiving extended frames with a different mailbox. I can provide code if needed.

0 Kudos
1 Reply

Contributor III

I assume that you use, the FlexCAN driver.

In most situations in the Automotive Industry, message configuration is done in the initialization part of the system. 

You have 64 mailboxes for each CAN instance, which you can configure as receive mailbox or transmit mailbox with the given ID. 

Also, you can configure each can instance as an Extended or Standard ID format part given below. If you want to change id type or id of the 

mailbox, you have to call the FLEXCAN_DRV_Init function in the runtime again. 



can1_rxtype.data_length = CAN_PACK_SIZE;
can1_rxtype.msg_id_type = FLEXCAN_MSG_ID_STD;

FLEXCAN_DRV_Init(CAN1, &canCom2_State, &canCom2_InitConfig0); // Initialization of FlexCAN module.


FlexCAN initialization process : 

Step 0 ) FLEXCAN_DRV_Init(CAN0, &canCom1_State, &canCom1_InitConfig0); // Initialization of FlexCAN module.

Step 1) FLEXCAN_DRV_ConfigRxMb(instance, ((pmailbox + i)->mb), &(rxtype),((pmailbox + i)->id)); // Initialization of CAN_RX, Mailbox and ID's

Step 2) FLEXCAN_DRV_Receive(instance, ((pmailbox + i)->mb), &((pmailbox + i)->msg));

Step 3) FLEXCAN_DRV_ConfigTxMb(instance, ((pmailbox + i)->mb), &txtype,((pmailbox + i)->id));

Step 4) ((mailbox + i)->msg).data[BYTE_0] = NULL; // message fill 

Your driver is ready to run. When you receive the message which has the id you have assigned in the FLEXCAN_DRV_ConfigRxMb function, you will receive an interrupt for a given channel. 

Best Wishes