Part Number: TMS320F280037
Other Parts Discussed in Thread: C2000WARE
Hey folks,
I am now working with a TMS320F280037 board and using its CAN bus for communication.
In the application, I have multiple TX, and RX message objects setup in main, something like
CAN_initModule(CANA_BASE);
CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 500000, 20);
CAN_enableInterrupt(CANA_BASE, CAN_INT_IE0 | CAN_INT_ERROR |CAN_INT_STATUS);
...
Interrupt_register(INT_CANA0, &canaISR);
Interrupt_enable(INT_CANA0);
CAN_enableGlobalInterrupt(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
// TX message object, # 1
CAN_setupMessageObject(CANA_BASE, 1, 0x111,
CAN_MSG_FRAME_STD, CAN_MSG_OBJ_TYPE_TX, 0,
CAN_MSG_OBJ_TX_INT_ENABLE, 8);
// TX message object, # 2
CAN_setupMessageObject(CANA_BASE, 2, 0x112,
CAN_MSG_FRAME_STD, CAN_MSG_OBJ_TYPE_TX, 0,
CAN_MSG_OBJ_TX_INT_ENABLE, 8);
// RX message object, # 3
CAN_setupMessageObject(CANA_BASE, 3, 0x101,
CAN_MSG_FRAME_STD, CAN_MSG_OBJ_TYPE_RX, 0,
CAN_MSG_OBJ_RX_INT_ENABLE, 8);
CAN_startModule(CANA_BASE);
and in the canaISR, I defined the action when each of the events (Transmission and receive interrupts) happens, something like
__interrupt void canaISR(void)
{
uint32_t intr_status;
uint32_t can_status;
//
// Read the CAN-B interrupt status to find the cause of the interrupt
//
intr_status = CAN_getInterruptCause(CANA_BASE);
//
// If the cause is a controller status interrupt, then get the status
//
switch (intr_status) {
case 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.
//
can_status = CAN_getStatus(CANA_BASE);
break;
}
case 3: // the RX message object # (which is 3)
{
// ... application codes
CAN_clearInterruptStatus(CANA_BASE, 3);
break;
}
case 1: // TX message object: 1
case 2: // TX message object: 2
{
// basically nothing to do here just clear the status
CAN_clearInterruptStatus(CANA_BASE, intr_status);
break;
}
default:
{
//
// Spurious interrupt handling can go here.
//
break;
}
} // end-switch
//
// Clear the global interrupt flag for the CAN interrupt line
//
CAN_clearGlobalInterruptStatus(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
//
// Acknowledge this interrupt located in group 9
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}
/************************CAN ISR**********************/
Now my observation is, the RX interrput gets correctly operated (the application codes in the RX switch case lines are operated, adding breakpoints it will stop there when a message was received). But the TX interrupt seems not happeing. Adding breakpoint in the TX Messag object switch case lines within canaISR, but not getting triggered.
I am expecting the TX interrupt to work properly since I have setup the TX message objects as CAN_MSG_OBJ_TX_INT_ENABLE. The RX message objects are setup in a similar manner (using CAN_MSG_OBJ_RX_INT_ENABLE) which works well, so I don't understand why the TX message objects have issue here.
Appreciate for replies and advices.
Regards,
Wei

