This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1294NCPDT: Add More CAN Frames

Part Number: TM4C1294NCPDT

Tool/software:

Hi.,

I am using TM4c1294NCPDT microcontroller.I transfer the data from one PCB to another PCB using CAN Controller. Here by i added my CAN Initialization CAN frames for your reference. Currently i am adding Single CAN frame for Occupied only 8bytes. I need to add more CAN  frames Like individual three 8 bytes CAN Frames.

CAN Initialization:

void CAN1_Initialize(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB0_CAN1RX);
GPIOPinConfigure(GPIO_PB1_CAN1TX);
GPIOPinTypeCAN(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN1);
CANInit(CAN1_BASE);
CANRetrySet(CAN1_BASE, true);//8470 @17-04-2023
CANBitRateSet(CAN1_BASE, g_ui32SysClkFreq, 500000);
CANIntRegister(CAN1_BASE, CAN1IntHandler);//@ 15-03-2023
CANIntEnable(CAN1_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
IntEnable(INT_CAN1);
CANEnable(CAN1_BASE);


g_CAN1MsgRx.ui32MsgID = CAN1RXID;
g_CAN1MsgRx.ui32MsgIDMask = 0;
g_CAN1MsgRx.ui32Flags = MSG_OBJ_RX_INT_ENABLE | MSG_OBJ_USE_ID_FILTER;
g_CAN1MsgRx.ui32MsgLen = sizeof(g_ui8CAN1RxData);
CANMessageSet(CAN1_BASE, CAN1RXOBJECT, &g_CAN1MsgRx, MSG_OBJ_TYPE_RX);
}

CAN TX Function

void CAN1_Tx_FUNCTION(void)
{

if((g_CAN1MsgRx.ui32MsgID >= 51)&&(g_CAN1MsgRx.ui32MsgID <= 60)) // CAN received from other PCB
{
uint8_t ui8Count=0;
uint8_t *CAN1_Tx_msgDataPtr;

CAN1_Tx_msgDataPtr = (uint8_t *)&g_ui8CAN1TxData;
for(ui8Count=0 ; ui8Count<sizeof(g_ui8CAN1TxData) ; ui8Count++)
{
g_ui8CAN1RxData[ui8Count] = 0;
}


g_ui8CAN1TxData[0] = Config.Configuration_No;
g_ui8CAN1TxData[1] = Config.Request_Reply;
g_ui8CAN1TxData[2] = Config.Status;
g_ui8CAN1TxData[3] =Suck_Back_Length;
g_ui8CAN1TxData[4] =Suction_Off_Timer;

g_ui8CAN1TxData[5] = g_PCB_SW_Version;
g_ui8CAN1TxData[6] = Fault_Event;
g_ui8CAN1TxData[7] = Fault_Length;

This is the single frame. I need to add more 8 byte frames for my application. I need a example for creating more CAN frames like(creating CAN ID etc).Please help me to make this CAN frames.

Thank you.

  • Currently i am adding Single CAN frame for Occupied only 8bytes. I need to add more CAN  frames Like individual three 8 bytes CAN Frames.

    Hi,

      You are currently using one Message Object (to receive one specific message ID (e.g. CAN1RXID as you define). You can use three more Message Objects to receive 3 additional CAN frames with its own message ID. Refer to the example C:\ti\TivaWare_C_Series-2.2.0.295\examples\peripherals\can\multi_rx.c where four message objects are used.