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.

TMS570LS0914: Is there a way to get a "timeout interrupt" if a CAN message is never received?

Part Number: TMS570LS0914
Other Parts Discussed in Thread: HALCOGEN

Hello,

I am using a TMS570 in a completely interrupt-driven environment.  Polling is generally not acceptable.  I would like to detect a failure of the CAN bus which has the effect of causing the TMS570 DCAN controller to keep resending the last message.  I know that I can disable resend, but that is also not desirable because generally you WANT it to resend if there is a collision or something.  The ideal situation would be for an error interrupt to come in if a message has stayed in the output buffer for longer than a certain time.  Is this possible?

Thanks for any ideas...

Burns

  • Burns,

    You can consider generating an interrupt on a status change and then look for the LEC error code to reflect an ACK error. The ISR can then keep a count of these events and perform the desired action if the message has been retransmitted and not acknowledged 'x' times.

  • Hi Sunit,

    I have enabled notifications for both status change and errors (using the routines generated by HalCoGen), but an interrupt never came for either.  Any thoughts about how to make such an interrupt happen?

  • Hi Burns,

    HALCoGen provides an example for interrupt-based CAN communication wherein it enables interrupt on CAN error flags. You can similarly enable interrupt on a status change. Note that this interrupt will be generated on all status changes, including when any message is correctly TX'ed or RX'ed.

  • Hi Sunil,

    I apologize that I am not being too clear, I guess.  I have interrupts working just fine via the HalCoGen "notify" routine.  I get interrupts when a messages arrive and when they are complete.  That all works very well.  I have also enabled status change and error notification.

    My problem is when I simulate a failure in the CAN bus.  In this case a message that I try to send is not acknowledged by another node on the bus, and thus that TMS570 DCAN keeps attempting to resend it.  This is appropriate for a time, and does not generate errors.  However, the problem is that it keeps resending forever.  At some point I would like it to give up and signal an error, which would generate an interrupt.

    So to summarize, interrupts are working fine.  However, even after many seconds (or minutes) of retrying transmissions, the DCAN module does not recognize an error or a status change.  I would like to know quickly if there is a CAN bus failure.  

    Ideas? -- Thanks.

  • Hi Burns,

    I should have been clearer as well. A status change interrupt is also generated whenever a transmitted CAN message is not acknowledged. This is not part of the CAN error interrupt, rather is just considered as a status change and is reflected by the LEC (Last Error Code = 3) bit-field in the CAN Error and Status register (DCAN ES). See below from the reference manual:

    A status change interrupt will be generated for all changes to the TX OK, RX OK, WakeUpPnd or LEC bit-fields. This is shown in section 24.10.3 in SPNU607a.

    You can have a counter implemented in the status-change ISR to track the number of times this interrupt is called for LEC = 3. This is not directly related to time units but you can take alternative action in software instead of allowing the CAN node to re-transmit the unacknowledged message forever.

  • Ok, thanks for highlighting that bit.  I am NOT getting a status change interrupt, but knowing that bit I can debug it better.  I'll let you know what I find.  I won't mark it resolved yet till I understand why it is not causing an interrupt.

  • Ok, more:  It turns out that LEC is staying at all ones, given that with my test, I never had a successful transmit to clear it.  But I am getting a Bus disconnect status change.  However, it does not generate an interrupt even though I enabled status change (and error) interrupts before that bus disconnect was discovered.

    That bit is helpful, and I guess I can deal with it, but I'm still wondering why it did not generate an interrupt.

  • Interrupts can be gated at three points:

    1. CPU: ensure that CPU response to an interrupt request is enabled. This needs to be done by calling the _enable_interrupt_() function from within your application.
    2. VIM (interrupt manager): each interrupt request is mapped to a particular VIM channel. This needs to be enabled within the VIM, and is configured via HALCoGen as described in the CAN Error Status interrupt example.
    3. Interrupt source: ensure that the specific condition is enabled as an interrupt condition within the DCANx module.

    Regards, Sunil

  • Well, as I said, all the interrupts are working fine EXCEPT for errors.  As far as I can tell, all the interrupts come in on the same interrupt request line, so I clearly have the VIM set up correctly.  Unless there is a different interrupt request line that I need to set up and that I can't find. 

    As I said, I also called both   canEnableErrorNotification and canEnableStatusChangeNotification which appear to set the specific condition that you mentioned (that is the CTL register bit 2 and bit 3, SIE and EIE.

    My HalCoGen has no example of the CAN error status interrupt under help/examples.  Can you give a pointer to it on the web, please?


     

  • In HALCoGen, click Help --> Help Topics

    In the window that opens up, clock on "Examples" to find the example for CAN communication with error status interrupts enabled.

  • Thanks.  I was being too literal and looking for "CAN Error Status Interrupt" in the help.  In any case, I think I have done everything specified in this example, but I'll play with it longer.

    Thanks for the help.

  • Ok, I found it.  Although I knew the interrupt enable bits had to be set AFTER CanInit, due to various routines I was calling, it happened backwards.  When I set the interrupt enable bits after calilng CanInit I get the interrupt as expected.

    Thanks very much for all the help!