Hardware manual
RX600 Series CAN Application Programming Interface
R01AN0339EU0203 Rev. 2.03 Page 4 of 29
Mar 23, 2013
3. Communication Layers
The figure below shows the CAN communication layers, with the application layer at the top and the hardware layer at
the bottom.
Figure 1. CAN physical and source code layers.
In this document we will not discuss any higher level protocols such as CANopen or DeviceNet. (For some Renesas
CAN MCUs there is a CANopen solution. Contact your sales representative.)
4. The Mailbox
When a CAN message is to be sent, it must first be written to a mailbox by the application firmware. It will then be sent
automatically as soon as the bus becomes idle, unless a message of lower ID is sent by another node. If a mailbox is
configured to receive, the message is written to the mailbox by the Protocol Controller and must be copied by the user,
using the API, to user memory area quickly to free the mailbox for the next message coming from the network.
The API calls will do all the writing to and from the mailbox for you. All you have to do is provide application data
frame structures which the API functions can write incoming messages to and copy outgoing messages from. It is
recommended to have a least one structure for outgoing messages, and one for incoming. For outgoing messages this
could be a local variable (on the stack). For incoming messages one for each mailbox is recommended. This CAN data
frame structure, of type can_std_frame_t, is provided by the API header file and has the following structure:
typedef struct
{
uint32_t id;
uint8_t dlc;
uint8_t data[8];
} can_frame_t;
Note that the timestamp is not included in this structure, but can easily be added.
Aside from CAN bus arbitration, priority is determined using the lowest mailbox number - except for SH (RCAN-ET)
where the highest mailbox has priority. This is true for both transmit and receive operations. If two mailboxes have
been set with the same CAN ID, the lowest mailbox number has the highest priority. Because of this, tf two mailboxes
are configured to receive with the same ID, one mailbox will never receive a message.
5. Using Extended ID
To use extended ID, the FRAME_ID_MODE must be set as explained in 0 below.
When Extended CAN is enabled, the API functions ending in ‘Xid’ can be called. These functions will automatically
cause the ID field of the CAN mailbox to be formatted to use extended ID. In other words the user need only call these
Xid-functions, and the ID value passed in the can_frame_t structure will be sent as a 29-bit ID (instead of 11-bit).