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: Questions about CAN in the 28388D

Part Number: TMS320F28388D

Tool/software:

Hi Engineer, I have recently debugged CAN in 28388D in CCS11.1 and my programme runs fine when the baud rate of CAN is 500K. But when I set the baud rate of CAN to 1000K, the
status = CAN_getInterruptCause(CANA_BASE); the return value status is 32768. I am posting my programme below:

#include "driverlib.h"
#include "device.h"
#define RX_MSG_OBJ_ID 1
#define MSG_DATA_LENGTH 8
//#define MSGCOUNT 16


__interrupt void canaISR(void);

volatile uint32_t errorFlag = 0;
char send_flag=0;
char send_buf[150] = {0};
uint16_t rxMsgData[8] = {0};
char send_temp_buf[150] = {0};
int send_temp_buf_i = 0;
char head_flag = 0;
uint16_t my_i = 0;
char heng_cnt = 0;
void main(void)
{
uint16_t t = 0;
//
// Initialize device clock and peripherals
//
Device_init();
//
// Initialize GPIO and configure GPIO pins for CANTX/CANRX
// on module A.
//
Device_initGPIO();
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXA);
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXA);
//
// Allocated shared peripheral to C28x
//
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_A,0x0U);
SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_B,0x0U);
//
// Initialize the CAN controllers
//
CAN_initModule(CANA_BASE);
//
// Set up the CAN bus bit rate
//
CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 1000000, 8);
//
// Enable interrupts on the CAN A peripheral.
//
CAN_enableInterrupt(CANA_BASE, CAN_INT_IE0 | CAN_INT_ERROR | CAN_INT_STATUS);
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
// This registers the interrupt handler in PIE vector table.
//
Interrupt_register(INT_CANA0,&canaISR);
//
// Enable the CAN-A interrupt signal
//
Interrupt_enable(INT_CANA0);
CAN_enableGlobalInterrupt(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
//
// Initialize the receive message object used for receiving CAN messages.
// Message Object Parameters:
// CAN Module: A
// Message Object ID Number: 1
// Message Identifier: 0x000000
// Message Frame: standard
// Message Type: Receive
// Message ID Mask: 0x0
// Message Object Flags: Receive Interrupt
// Message Data Length: 8 Bytes (Note that DLC field is a "don't care"
// for a Receive mailbox
//
CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, 0x000000,CAN_MSG_FRAME_STD, CAN_MSG_OBJ_TYPE_RX, 0,CAN_MSG_OBJ_RX_INT_ENABLE, MSG_DATA_LENGTH);
//
// Start CAN module A operations
//
CAN_startModule(CANA_BASE);
//

//SCIB TX 422
GPIO_setMasterCore(10, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_10_SCIB_TX);
GPIO_setDirectionMode(10, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(10, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(10, GPIO_QUAL_ASYNC);

SCI_setConfig(SCIB_BASE, DEVICE_LSPCLK_FREQ, 256000, (SCI_CONFIG_WLEN_8 | SCI_CONFIG_STOP_ONE | SCI_CONFIG_PAR_NONE));
SCI_resetChannels(SCIB_BASE);
SCI_enableModule(SCIB_BASE);
SCI_performSoftwareReset(SCIB_BASE);

while(1)
{
if(send_flag)
{
send_flag = 0;
GPIO_writePin(DEVICE_GPIO_PIN_422, 0);
t=0;
for(t=1;t<150;t++)
{
SCI_writeCharBlockingNonFIFO(SCIB_BASE, send_buf[t]);
if(send_buf[t] == '\n')
{
send_buf[t] = 0;
break;
}
send_buf[t] = 0;
}
}
}
}
__interrupt void canaISR(void)
{
uint16_t i = 0;
uint32_t status = 0;
//
// Read the CAN interrupt status to find the cause of the interrupt
//
status = CAN_getInterruptCause(CANA_BASE);
//
// If the cause is a controller status interrupt, then get the status
//
if(status == CAN_INT_INT0ID_STATUS)
{
status = CAN_getStatus(CANA_BASE);
if(((status & ~(CAN_STATUS_RXOK)) != CAN_STATUS_LEC_MSK) && ((status & ~(CAN_STATUS_RXOK)) != CAN_STATUS_LEC_NONE))
{
errorFlag = 1;
}
}
else if(status == RX_MSG_OBJ_ID)
{
//
// Get the received message
//
CAN_readMessage(CANA_BASE, RX_MSG_OBJ_ID, rxMsgData);
for(i=0;i<8;i++)
{
if(rxMsgData[i] == '$')
{
GPIO_writePin(DEVICE_GPIO_PIN_CANA, 0);
head_flag = 1;
send_temp_buf_i = 0;
}
if(head_flag)
{
if(rxMsgData[i] == 0)
{
continue;
}
if(rxMsgData[i] == ',')
{
heng_cnt++;
}
send_temp_buf[send_temp_buf_i++] = rxMsgData[i];
}
if(rxMsgData[i] == '\n' && heng_cnt >= 18)
{
for(my_i=0;my_i<send_temp_buf_i;my_i++)
{
send_buf[my_i] = send_temp_buf[my_i];
send_temp_buf[my_i] = 0;
if(send_buf[my_i] == '\n')
break;
}
head_flag = 0;
send_flag = 1;
send_temp_buf_i = 0;
heng_cnt = 0;
rxMsgData[i] = 0;
GPIO_writePin(DEVICE_GPIO_PIN_CANA, 1);
break;
}
}
CAN_clearInterruptStatus(CANA_BASE, RX_MSG_OBJ_ID);
errorFlag = 0;
}
CAN_clearGlobalInterruptStatus(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}