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.

TMS320F280048C-Q1: DCAN: How can I use both CANINT0 and CANINT1 at the same time?

Part Number: TMS320F280048C-Q1

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;
    }
}

  • Hi Mina,

    Thanks for your question! Diving right into it:

        // Enable CAN Interrupts
        CAN_enableInterrupt(CAN_BASE, CAN_INT_IE1|CAN_INT_STATUS);

    INT1 is actually not able to interrupt on STATUS or ERROR sources, only on RX/TX interrupts. See diagrams below from TRM for differences between the interrupt topologies. The top is where SIE (status change interrupts) and EIE (error interrupts)  can be detected. Notice how they are only for CAN0INT, not for CAN1INT.

    So in order to get the RxIE to pass through to the CAN1INT (from the lower diagram) you'll need to do the following.

    1. First, only enable CAN_INT_IE1:

        // Enable CAN Interrupts
        CAN_enableInterrupt(CAN_BASE, CAN_INT_IE1);

    EDIT: The mux update code provided in the original response is correct for Message Object 1.

    Updated request:

    2. Please provide a scope/logic analyzer capture of the RX pin during reception to ensure that the received baud rate is as expected. Also please provide any error status values to ensure the packet is potentially being "incorrectly" received, but not triggering an ISR.

    Regards,

    Vince

  • Hi Vince,

    I appreciate your response. Unfortunately, I cannot provide any captures, but my CAN transmission is working properly if I disable the SIE.

    For now, I have disabled the SIE and my code is working.