Hi. I used MPC5634M.
I want to set CAN ID to 0x1806E5F4. But, I can set CAN ID up to 0xFFF.
code;
/*******************************************************************************
Function Name : TransmitMsg
Engineer : stnp002
Date : Mar-21-2012
Parameters : NONE
Modifies : NONE
Returns : NONE
Notes : FlexCANA simple transmit. per AN2865
Issues : NONE
*******************************************************************************/
static void TransmitMsg(void) //TransmitMsg
{
uint8_t i;
//Assumption: Message buffer CODE is INACTIVE
const uint32_t TxData[8] = {0x02,0x88,0x03,0xE8,0x00,0x00,0x00,0x00}; //Transmit hex
CAN_A.BUF[0].CS.B.IDE = 0; //Use standard ID length
CAN_A.BUF[0].ID.B.STD_ID = 0x1806E5F4; //Transmit ID
CAN_A.BUF[0].CS.B.RTR = 0; //Data frame, not remote Tx request frame
//CAN_A.BUF[0].CS.B.LENGTH = sizeof(TxData) -1 ; //# bytes to transmit w/o null
CAN_A.BUF[0].CS.B.LENGTH = 8 ; //# bytes to transmit w/o null
//for (i=0; i<sizeof(TxData); i++)
for (i=0; i<8; i++)
{
CAN_A.BUF[0].DATA.B[i] = TxData[i]; //Data to be transmitted
}
CAN_A.BUF[0].CS.B.SRR = 1; //Tx frame (not req'd for standard frame)
CAN_A.BUF[0].CS.B.CODE =0xC; //Activate msg. buf. to transmit data frame
}
in "CAN_A.BUF[0].ID.B.STD_ID", it can set CAN ID up to 0xFFF.
Hi,
Set the IDE bit to use the extended (29-bit) ID and use the register access to fill the ID word, like following:
CAN_A.BUF[0].CS.B.IDE = 1; //Use extended ID length
CAN_A.BUF[0].ID.R = 0x1806E5F4; //Transmit ID
BR, Petr
Thank you very much :smileyhappy: