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.

CAN Frame Adding issue

Other Parts Discussed in Thread: TM4C1294NCPDT

Hi.,

I'm working on TM4C1294NCPDT microcontroller.I transmit the data from one PCB to another PCB.And also receoves the data using CAN communication protocol.

My question is, i transfer the data from CAN in engaged this CAN frame in 8 bytes. I ned to add more frames.For ex:

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);
CANBitRateSet(CAN1_BASE, g_ui32SysClkFreq, 500000);
CANIntRegister(CAN1_BASE, CAN1IntHandler);
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 Transmission:

void CAN1_Tx_FUNCTION(void)
{
if((g_CAN1MsgRx.ui32MsgID >= 51)&&(g_CAN1MsgRx.ui32MsgID <= 60))
{
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_ui8CAN1TxData[0] =Configuration_No;
g_ui8CAN1TxData[1] = Request_Reply;
g_ui8CAN1TxData[2] = Status;
g_ui8CAN1TxData[3] = RetryAttempt_Count;
g_ui8CAN1TxData[4] =Clearer_Yarn_Status;
g_ui8CAN1TxData[5] =Clearer_Status_Ready;
g_ui8CAN1TxData[6] = Fault_Event;
g_ui8CAN1TxData[7] =Fault_Length;

I have to add more data to transmit another PCB. How to add another CAN frame please guide me or susggest me for any example for adding CAN frame.

If i have to continue  g_ui8CAN1TxData[8] =Reserved; or add  new frame,how to add.Please give me the solution 

Thanks in advance.

  • Hi,

     [Edit 10/12/2023]

      CAN supports up to 64bits of payload which is 8 bytes per frame. Please reference the multi_tx.c and multi_rx.c in C:\ti\TivaWare_C_Series-2.2.0.295\examples\peripherals\can. These two examples illustrate setting up multiple message objects for sending and receiving.  

  • Hi,

      I have not heard back from you. As I mentioned, the CAN payload is 8 bytes only. If you need to transmit more data with the same arbitration ID then you just load your payload with different data. If you want to send with different arbitration ID then you can use a different Message Object.