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.

TMS470MF06607: CAN error Notification

Part Number: TMS470MF06607
Other Parts Discussed in Thread: HALCOGEN

Hello,

I am currently developing a CAN sniffer in which an error on CAN is identified using CAN error notification. I tried to test this by not connecting anything on CAN and try to shoot Transmission.

For the first time, all is well I see that as soon as I try to transmit the very first message, an interrupt on CAN occurs and since there is error indication, it will jump to notification,

Now the problem is, second time I try to send the CAN, nothing happens and no notification. Am I supposed to clear some flag or something? 

What I need is that I should hit error notification every time I try to transmit a CAN on an unconnected node. How do I achieve this?

Regards,

Shankar

  • You do have to clear the pending interrupt flag in the CAN module. Have you looked at the interrupt code generated by HALCoGen?

    /** @fn void can1HighLevelInterrupt(void)
    *   @brief DCAN1 High Level Interrupt Handler
    */
    
    /* USER CODE BEGIN (40) */
    /* USER CODE END */
    
    #pragma INTERRUPT(can1HighLevelInterrupt)
    void can1HighLevelInterrupt(void)
    {
        uint32 value = canREG1->INT;
    
    /* USER CODE BEGIN (41) */
    /* USER CODE END */
    
        if (value == 0x8000U)
        {
            canErrorNotification(canREG1, canREG1->ES & 0x1E0U);
            return;
        }
    
        /** - Setup IF1 for clear pending interrupt flag */
        while ((canREG1->IF1STAT & 0x80U) ==0x80U)
        { 
    	} /* Wait */
    
        canREG1->IF1CMD = 0x08;
        canREG1->IF1NO  = value;
    
        while ((canREG1->IF1STAT & 0x80U) ==0x80U)
        { 
    	} /* Wait */
    
        canREG1->IF1CMD = 0x87;
    
        canMessageNotification(canREG1, value);
    
    /* USER CODE BEGIN (42) */
    /* USER CODE END */
    }
    
    

  • Thanks Bob. I see I have been a bit stupid!

    #update 

    I guess I was too quick for a conclusion. Even After I changed the code as shown below, the interrupts never occur. Anything else missing?

    void can2HighLevelInterrupt(void)
    {
        uint32 value = canREG2->INT;
    
    /* USER CODE BEGIN (47) */
    /* USER CODE END */
    
        if (value == 0x8000U)
        {
            while ((canREG2->IF1STAT & 0x80U) ==0x80U)
            { 
    	} /* Wait */
    
            canREG2->IF1CMD = 0x08;
            canREG2->IF1NO  = value;
            canErrorNotification(canREG2, canREG2->ES & 0x1E0U);
            return;
        }

  • OK, not sure what the issue is so let's look at your HALCoGen configuration and I have attached a simple example that works. The example transmits on CAN1 and receives on CAN2.

    Did you enable interrupts for CAN2?

    Did you enable VIM channel 29?

    Here is my sample project:

    /cfs-file/__key/communityserver-discussions-components-files/312/8407.InterruptCanCommunication.zip

  • Hello Bob,

    Thanks for the response. Yes the interrupts are enabled. Infcat, am getting the message interrupts and notification like a charm. No issues when I have a healthy CAN node. The problem only is in the error notification.

    Regards,

    Shankar

  • Did the DCAN go into Bus-Off state?  Did you configure the device to use the Auto-Bus-On feature?

  • Hello Bob,

    Yes I did configure the bus for an auto recovery. And also since I left the CAN channel open (open Ckt) I am pretty sure it would have reached a BUss-off State. Wont it notify an error when it tries to transmit in Buss-off state?

    Regards,

    Shankar