Part Number: TMS320F28377S
Hi,
I am using LAUNCHXL-F28377S development board.
I have modified the can_external_transmit example such that only CANA is used as I intend to use the development board's CAN transceivers.
I have an external node (Komodo CAN Controller) which is transmitting the data periodically every second and TMS320F8377S should receive it.
I am getting the status interrupt CAN_INT_INT0ID_STATUS for CAN_INT_STS_CAUSE and then inside I am getting CAN_ES_RXOK for CAN_STS_CONTROL in the ISR code below. But I am not receiving any status interrupt for RX_MSG_OBJ_ID and hence I am not able to get any received data. What could be possibly wrong with my code?
void CAN_Init(void)
{
CANInit(CANA_BASE);
CANClkSourceSelect(CANA_BASE, 0); // 1000kHz CAN-Clock
CANBitRateSet(CANA_BASE, 50000000, 1000000);
CANIntEnable(CANA_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
CANGlobalIntEnable(CANA_BASE, CAN_GLB_INT_CANINT0);
sRXCANMessage.ui32MsgID = 1;
sRXCANMessage.ui32MsgIDMask = 0;
sRXCANMessage.ui32Flags = MSG_OBJ_RX_INT_ENABLE;
sRXCANMessage.ui32MsgLen = 4;
sRXCANMessage.pucMsgData = rxMsgData;
CANMessageSet(CANA_BASE, RX_MSG_OBJ_ID, &sRXCANMessage,
MSG_OBJ_TYPE_RX);
CANEnable(CANA_BASE);
}
__interrupt void canaISR(void)
{
uint32_t status;
//
// Read the CAN-A interrupt status to find the cause of the interrupt
//
status = CANIntStatus(CANA_BASE, CAN_INT_STS_CAUSE);
//
// If the cause is a controller status interrupt, then get the status
//
if(status == CAN_INT_INT0ID_STATUS)
{
//
// Read the controller status. This will return a field of status
// error bits that can indicate various errors. Error processing
// is not done in this example for simplicity. Refer to the
// API documentation for details about the error status bits.
// The act of reading this status will clear the interrupt.
//
status = CANStatusGet(CANA_BASE, CAN_STS_CONTROL);
//
// Check to see if an error occurred.
//
if(((status & ~(CAN_ES_RXOK)) != 7) &&
((status & ~(CAN_ES_RXOK)) != 0))
{
//
// Set a flag to indicate some errors may have occurred.
//
errorFlag = 1;
}
}
//
// Check if the cause is the CAN-A receive message object 1
//
else if(status == RX_MSG_OBJ_ID)
{
printf("Primary OBC reading CAN bus\n\r");
//
// Get the received message
//
CANMessageGet(CANA_BASE, RX_MSG_OBJ_ID, &sRXCANMessage, true);
//
// Getting to this point means that the RX interrupt occurred on
// message object 1, and the message RX is complete. Clear the
// message object interrupt.
//
CANIntClear(CANA_BASE, RX_MSG_OBJ_ID);
//
// Increment a counter to keep track of how many messages have been
// received. In a real application this could be used to set flags to
// indicate when a message is received.
//
rxMsgCount++;
//
// Since the message was received, clear any error flags.
//
errorFlag = 0;
rcvd_data = 1;
}
//
// If something unexpected caused the interrupt, this would handle it.
//
else
{
//
// Spurious interrupt handling can go here.
//
}
//
// Clear the global interrupt flag for the CAN interrupt line
//
CANGlobalIntClear(CANA_BASE, CAN_GLB_INT_CANINT0);
//
// Acknowledge this interrupt located in group 9
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;
}