Hardware manual
RX600 Series CAN Application Programming Interface
R01AN0339EU0203 Rev. 2.03 Page 21 of 29
Mar 23, 2013
R_CAN_CheckErr
Check for bus errors
The API checks the CAN status, or Error State, of the CAN peripheral.
Format
uint32_t R_CAN_CheckErr(const uint32_t ch_nr);
Parameters
ch_nr 0,1,2,3 Which CAN bus to use. 1-4 channels may be available.
urn Values
CAN_STATE_ERROR_ACTIVE CAN Bus Status: Normal operation.
CAN_STATE_ERROR_PASSIVE CAN Bus Status: The node has sent at least 127 Error frames for either the
Transmit Error Counter, or the Receive Error Counter.
CAN_STATE_BUSOFF CAN Bus Status: The node’s Transmit Error Counter has surpassed 255
due to the node’s failure to transmit correctly.
Properties
Prototyped in r_can_api.h
Implemented in r_can_api.c
Comments
The API checks the CAN status flags of the CAN peripheral and returns the status error code. It tells whether the
node is in a functioning state or not and is used for application error handling.
It should be polled either routinely from the main loop, or via the CAN error interrupt. Since the peripheral
automatically handles retransmissions and Error frames it is usually of no advantage to include an error
interrupt routine.
If an error state is encountered the application can just wait and monitor for the peripheral to recover, as the CAN
peripheral takes itself on or off line depending on its state. After a recovery is discovered, the application
should restart.
Bus States
CAN is designed to protect network communication in the event that any CAN network node becomes faulty.
Every time the transmitter sees an Error flag, the Transmit Error Counter is increased, and when an error in a
received frame is detected, the Receive Error Counter is increased. The Transmit and Receive Error Counters
are respectively decreased with every successfully transmitted or received frame. In both the Error Active state
(the normal operating state) and the Error Passive State, messages can be transmitted and received.