Hardware manual

RX600 Series CAN Application Programming Interface
R01AN0339EU0203 Rev. 2.03 Page 25 of 29
Mar 23, 2013
The CAN error interrupt can be used to check the error state of the node, although polling with the API regularly is
usually sufficient since low level error handling is done by the peripheral.
The API can be called from the error ISR to determine the error state, and then flag the application if a state
transition has occurred. Most often the Transmit or Receive Error Counter will have just incremented.
Interrupts can be enabled separately for each of: A single error, transition to Error Passive, and transition to Bus
Off. If the first of these, the CAN Error interrupt is enabled, an interrupt is generated each time an error is
detected. Again, generating this interrupt is usually unnecessary as CAN handles errors on its own.
9. CAN Interrupt Checklist
6. Use this checklist to make sure interrupts are set up correctly, and if you are having problems getting the interrupts
to trigger.
7. Tell the compiler to do a ‘return from interrupt’ for your ISR with the #pragma directive. This must be present in
the file where the function is defined. Example:
#pragma interrupt CAN0_RXM0_ISR(vect=VECT_CAN0_RXM0, enable)
void CAN0_RXM0_ISR(void)
{…
8. Are interrupts enabled globally with e.g. the ENABLE_IRQ macro somewhere? If your interrupt does not occur,
the flag may have been disabled (by e.g. DISABLE_IRQ). Check by doing this: At a point in the code where your
interrupt is expected, set a breakpoint and check that the I-flag is '1'. Check the CPU flag registers for the I-flag.
9. Is the interrupt priority level for the interrupt set to a non-zero value? Check the main Interrupt chapter of the HW
manual.
10. Is the respective mailbox’s interrupt flag enabled?
11. Is the CAN interrupt mask register set to mask off the interrupt?
12. To nest CAN interrupts, that is, enable other interrupts to preempt an ongoing CAN interrupt, add the “enable
argument to the vector declaration as in the example above.
13. Make sure that the interrupt ISR function is pointed to correctly by the vector table. Check the interrupt base
register and count the offset from there to see the CAN interrupt ISR address in the interrupt table.
10. Test Modes
There are test modes that may be useful for example during product development. There are two loopback modes
“Internal” and “External, and also a Listen only mode.
10.1 Internal Loopback - Test Node Without CAN Bus
Internal Loopback mode, or Self Test mode, allows you to communicate via the CAN mailboxes without connecting to
a bus. This can be useful for testing an application, or self-diagnosis during application debug.
The node acknowledges its own data with the ACK bit in the data frame. The node also stores its own transmitted
messages into a receive mailbox if it was configured for that CAN ID. This is normally not possible.