Hardware manual
RX600 Series CAN Application Programming Interface
R01AN0339EU0203 Rev. 2.03 Page 9 of 29
Mar 23, 2013
R_CAN_PortSet
Configures the MCU and transceiver port pins
This function is responsible for configuring the MCU and transceiver port pins. Transceiver port pins such as Enable
will vary depending on design, and this function must then be modified.
The function is also used to enter the CAN port test modes, such as Listen Only.
Format
uint32_t R_CAN_PortSet( const uint32_t ch_nr,
const uint32_t action_type );
Arguments
ch_nr 0,1,2,3 Which CAN bus to use. The number of available channels
depends on part. 1-4 channels may be available.
action_type Port actions:
ENABLE Enable the CAN port pins and the CAN transceiver.
DISABLE Disable the CAN port pins and the CAN transceiver.
CANPORT_TEST_LISTEN_ONLY Set to Listen Only mode. No Acks or Error frames are
sent. See 10.3.
CANPORT_TEST_0_EXT_LOOPBACK Use external bus and loopback. Not tested!
CANPORT_TEST_1_INT_LOOPBACK Only internal mailbox communication.
CANPORT_RETURN_TO_NORMAL Return to normal port usage.
Return Values
R_CAN_OK Action completed successfully.
R_CAN_SW_BAD_MBX Bad mailbox number.
R_CAN_BAD_CH_NR The channel number does not exist.
R_CAN_BAD_ACTION_TYPE No such action type exists for this function.
R_CAN_SW_HALT_ERR The CAN peripheral did not enter Halt mode.
R_CAN_SW_RST_ERR The CAN peripheral did not enter Reset mode.
See also R_CAN_Control return values.
Properties
Prototyped in r_can_api.h
Implemented in r_can_api.c
Comments
Make sure this function is called before and after any default port set up function is used (e.g. ‘hwsetup’). Otherwise,
an output high/low on an MCU CAN port pin could affect the bus. (You may discover when debugging that a hard reset
on a node could cause other nodes to go into error mode. The reason may be that all ports were set as default output
hi/low before CAN reconfigures the ports. For a brief period of time, the ports will then be output low and disrupt the
CAN bus voltage level.)
You may have to change/add transceiver port pins according to your transceiver.
Example
/* Normal CAN bus usage. */
R_CAN_PortSet(0, ENABLE);