Other Parts Discussed in Thread: TMS320F280037, C2000WARE
主题中讨论的其他器件: C2000WARE
大家好、
我现在使用 TMS320F280037电路板、并使用其 CAN 总线进行通信。
在应用程序中、我在 main 中设置了多个 TX 和 RX 消息对象、例如
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);
在 canaISR 中、我定义了每个事件(传输和接收中断)发生时的操作、类似于
__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**********************/
现在我的观察是、RX 输入正确运行(RX 开关 case 行中的应用代码被运行、添加了在接收到消息时它将在那里停止的断点)。 但 TX 中断似乎未满足要求。 在 TX Messag 对象中添加断点会在 canaISR 内切换 case 行、但不会被触发。
因为我已经将 TX 消息对象设置为 CAN_MSG_OBJ_TX_INT_ENABLE、所以我希望 TX 中断正常工作。 RX 消息对象采用类似的设置方式(使用 CAN_MSG_OBJ_RX_INT_ENABLE)、效果很好、因此我不明白为什么 TX 消息对象在这里有问题。
感谢您的回复和建议。
此致、
魏

