AnsweredAssumed Answered

Will someone please provide a CAN message object config code example to only receive only CAN extended ID 29 bit id based CAN messages on the LPC11C24. I have modified the CAN_ConfigureMessages in the example code as below, but its still not working

Question asked by Sudarshan S on Apr 18, 2017
Latest reply on Apr 21, 2017 by VN V

The CAN messages are being transmitted and received successfully in the Standard ID mode already.

/* Data structure for a CAN message */
typedef struct
{
uint32_t id;
uint32_t dlc;
uint32_t data[4];
} message_object;

 

#define MSG_OBJ_MAX 0x0020
#define DLC_MAX 8

#define RX_MSG_ID 0x300
#define RX_EXT_MSG_ID 0x00100000

#define TX_MSG_ID 0x200
#define TX_EXT_MSG_ID 0x00200000

 

void CAN_ConfigureMessages( void )
{
uint32_t i;
uint32_t ext_frame = 0;

/* extended receive only for 32 objects */

for ( i = 0; i < MSG_OBJ_MAX; i++ )
{
   LPC_CAN->IF1_CMDMSK = WR|MASK|ARB|CTRL|DATAA|DATAB;

 

   /* Mxtd: 1, Mdir: 0, Mask is 0x1FFFFFFF*/
   LPC_CAN->IF1_MSK1 = ID_EXT_MASK & 0xFFFF;
   LPC_CAN->IF1_MSK2 = MASK_MXTD | (ID_EXT_MASK >> 16);

 

   /*MsgVal: 1, Mtd: 1, Dir: 0, ID = 0x100000*/
   LPC_CAN->IF1_ARB1 = (RX_EXT_MSG_ID+i) & 0xFFFF;
   LPC_CAN->IF1_ARB2 = ID_MVAL | ID_MTD | ((RX_EXT_MSG_ID+i) >> 16);

   LPC_CAN->IF1_MCTRL = UMSK|RXIE|EOB|DLC_MAX;

   LPC_CAN->IF1_DA1 = 0x0000;
   LPC_CAN->IF1_DA2 = 0x0000;
   LPC_CAN->IF1_DB1 = 0x0000;
   LPC_CAN->IF1_DB2 = 0x0000;

   /* Transfer data to message RAM */
   LPC_CAN->IF1_CMDREQ = i+1;

   while( LPC_CAN->IF1_CMDREQ & IFCREQ_BUSY );
}
   return;
}

Outcomes