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.

TMS320F28388D:TMS320F28388D: Questions about CAN in the 28388D

Part Number: TMS320F28388D


Tool/software:

Hi Engineer.

I have problem about can. 

I wrote my_can.c and my_can.h, and then called the functions my_can_init, my_can_receive, and my_can_transmit from main_cpu1.c.
I also declared memory and sections properly in the cmd file, but as shown in the attached picture, it still shows that memory is not allocated.

How can I fix this issue?

I am attaching the my_can.c code.

/*
* my_can.c
*
* Created on: 2025. 8. 23.
* Author: 82102
*/
#include "my_can.h"
//#include "can.h"

#define TXCOUNT 100000

#define MSG_DATA_LENGTH 8
#define TX_MSG_OBJ_ID 1
#define RX_MSG_OBJ_ID 1
#define TX_MSG_ID 0x100
#define RX_MSG_ID 0x100

void my_can_init();
void my_can_transmit();
void my_can_receive();


volatile unsigned long i;

uint16_t txMsgData[8];
uint16_t rxMsgData[8];

//Can Setting


void my_can_init()
{
// GPIO_setPadConfig(70, GPIO_PIN_TYPE_PULLUP); // Enable pullup on GPIO30
// GPIO_setPinConfig(GPIO_70_CANA_RX); // GPIO30 = CANRXA
// GPIO_setPadConfig(71, GPIO_PIN_TYPE_PULLUP); // Enable pullup on GPIO31
// GPIO_setQualificationMode(71, GPIO_QUAL_ASYNC); // asynch input
// GPIO_setPinConfig(GPIO_71_CANA_TX); // GPIO31 = CANTXA


//--> Initialize the CAN controller
CAN_initModule(CANA_BASE);

// <--Initialize the CAN controller


//<-- Set up the CAN bus bit rate to 500kbps for each module
// Refer to the Driver Library User Guide for information on how to set
// tighter timing control. Additionally, consult the device data sheet
// for more information about the CAN module clocking.
//
CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 500000, 16);

//--> Initialize the receive message object used for receiving CAN messages.
// Possible flags: CAN_MSG_OBJ_NO_FLAGS, CAN_MSG_OBJ_USE_EXT_FILTER,
// CAN_MSG_OBJ_USE_DIR_FILTER
// Initialize the transmit message object used for sending CAN messages.
// Message Object Parameters:
// CAN Module: A
// Message Object ID Number: 1
// Message Identifier: 55
// Message Frame: Standard
// Message Type: Transmit
// Message ID Mask: 0x0
// Message Object Flags: None
// Message Data Length: 4 Bytes

CAN_setupMessageObject(CANA_BASE, TX_MSG_OBJ_ID, TX_MSG_ID,
CAN_MSG_FRAME_STD, CAN_MSG_OBJ_TYPE_TX, 0,
CAN_MSG_OBJ_NO_FLAGS, MSG_DATA_LENGTH);


//--> Initialize the receive message object used for receiving CAN messages.
// Message Object Parameters:
// CAN Module: B
// Message Object ID Number: 1
// Message Identifier: 33
// Message Frame: Standard
// Message Type: Receive
// Message ID Mask: 0x0
// Message Object Flags: Receive Interrupt
// Message Data Length: 4 Bytes
//
CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, RX_MSG_ID,
CAN_MSG_FRAME_STD, CAN_MSG_OBJ_TYPE_RX, 0,
CAN_MSG_OBJ_NO_FLAGS, MSG_DATA_LENGTH);

//<-- Initialize the transmit message object data buffer to be sent
txMsgData[0] = 0x12;
txMsgData[1] = 0x34;
txMsgData[2] = 0x56;
txMsgData[3] = 0x78;
//--> Initialize the transmit message object data buffer to be sent


//<--Start CAN module B operations
CAN_startModule(CANA_BASE);
//CAN_enableTestMode(CANA_BASE,CAN_TEST_LBACK);
//--> Start CAN module B operations

}

void my_can_transmit()
{
//--> User Code
// Increment the value in the transmitted message data.
//

CAN_sendMessage(CANA_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH, txMsgData);
txMsgData[0] += 0x01;
// txMsgData[1] += 0x01;
// txMsgData[2] += 0x01;
// txMsgData[3] += 0x01;

// Reset data if exceeds a byte
//
if(txMsgData[0] > 0xFF)
{
txMsgData[0] = 0;
}
if(txMsgData[1] > 0xFF)
{
txMsgData[1] = 0;
}
if(txMsgData[2] > 0xFF)
{
txMsgData[2] = 0;
}
if(txMsgData[3] > 0xFF)
{
txMsgData[3] = 0;
}
//<-- User Code
}

void my_can_receive()
{
// Get the received message
//
CAN_readMessage(CANA_BASE, RX_MSG_OBJ_ID, rxMsgData);
rxMsgCount ++;

}