Hi Experts,
According to the thread I linked to, how can both interrupt lines be used at the same time?
In my code, CANINT0 is for checking the TxOk status for transmitting packets, so I know if my message is transmitted successfully. I also want to get an interrupt when a packet is received by CANINT1's global interrupt. However, I do not get any interrupts when a message object is received. How can I fix this?
Here are a few parts of my code:
void CAN_init(void) { //CAN initialization CAN_initModule(CAN_BASE); // 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(CAN_BASE, DEVICE_SYSCLK_FREQ, 100000, 20); // Enable CAN Interrupts CAN_enableInterrupt(CAN_BASE, CAN_INT_IE1|CAN_INT_STATUS); CAN_enableGlobalInterrupt(CAN_BASE, CAN_GLOBAL_INT_CANINT1); // Initialize the transmit message object used for sending CAN messages. // Message Object Parameters: // Message Object ID Number: 1 // Message Identifier: 1 // Message Frame: CAN_MSG_FRAME_STD // Message Type: CAN_MSG_OBJ_TYPE_RX // Message ID Mask: 0 // Message Object Flags: CAN_MSG_OBJ_RX_INT_ENABLE // Message Data Length: 8 Bytes // CAN_setupMessageObject(CAN_BASE, 1, 1, CAN_MSG_FRAME_STD,CAN_MSG_OBJ_TYPE_RX, 0, CAN_MSG_OBJ_RX_INT_ENABLE,8); // Initialize the transmit message object used for sending CAN messages. // Message Object Parameters: // Message Object ID Number: 2 // Message Identifier: 2 // Message Frame: CAN_MSG_FRAME_STD // Message Type: CAN_MSG_OBJ_TYPE_TX // Message ID Mask: 0 // Message Object Flags: CAN_MSG_OBJ_TX_INT_ENABLE // Message Data Length: 8 Bytes // CAN_setupMessageObject(CAN_BASE, 2, 2, CAN_MSG_FRAME_STD,CAN_MSG_OBJ_TYPE_TX, 0, CAN_MSG_OBJ_TX_INT_ENABLE,8); CAN_setInterruptMux(CAN_BASE, 2); <-----------to use CANINT1 for msg obj 1 // // Start CAN module operations // CAN_startModule(CAN_BASE); };
CANINT1 is the only interrupt I enable:
// // This registers the interrupt handler in PIE vector table. // Interrupt_register(INT_CANB1, &ISR_can1); // // Enable the CAN-B interrupt signal // Interrupt_enable(INT_CANB1);
I use the following code to verify successful transmission:
bool canGetTxOkStatus(void)
{
uint16_t status;
status = CAN_getStatus(CAN_BASE);
if ( (status & CAN_STATUS_TXOK) == CAN_STATUS_TXOK)
{
return true;
}
else
{
return false;
}
}