APPLICATION NOTE RX62N Group, RX621 Group RIIC Multi-Master Communication R01AN0630EJ0100 Rev.1.00 Sep 27, 2011 Introduction This application note presents an example of communication in multi-master mode using the RIIC (I2C bus interface) module provided by Renesas microcontrollers.
RX62N Group, RX621 Group 1. RIIC Multi-Master Communication Specifications This sample program first performs a master mode transmission operation (10 bytes) and then performs a master mode reception operation (10 bytes). It uses a communication bit rate of 100 kbps. Table 1 lists peripheral functions used and their application and figure 1 shows the connection diagram.
RX62N Group, RX621 Group 2. RIIC Multi-Master Communication Operation Verification Environment Operation of the sample code provided in this application note has been verified in the following environment. Table 2 Operation Verification Environment Item Microcontroller used Operating frequency Operating voltage Integrated development environment Compiler Operating mode Sample code version Board used R01AN0630EJ0100 Rev.1.
RX62N Group, RX621 Group 3. RIIC Multi-Master Communication Software Description 3.1 Operation Overview • The program performs master mode transmission. If the arbitration lost state is detected during master mode transmission, the communication of the other master device is given priority and the program switches to slave mode operation. • The program performs master mode reception.
RX62N Group, RX621 Group 3.3 RIIC Multi-Master Communication Constants Table 5 lists the constants used in the sample code. Table 5 Constants Constant RIIC_OK RIIC_NG RIIC_BUS_BUSY RIIC_ST_MST_IDLE RIIC_ST_MST_BUSY RIIC_ST_MST_NACK RIIC_ST_MST_AL RIIC_ST_MST_TMO RIIC_ST_MST_COMPLETE RIIC_SET RIIC_CLEAR SELF_ADDRESS MST_DATA_NUM SLV_DATA_NUM MST_WRITE MST_READ 3.4 Setting Value 0 1 2 0 1 2 3 4 5 1 0 0x10 (10+1) 10 0x00 0x01 Description Used as the return value of the RiicStart() function.
RX62N Group, RX621 Group 3.5 RIIC Multi-Master Communication Functions Table 8 lists the functions.
RX62N Group, RX621 Group 3.6 RIIC Multi-Master Communication Function Specifications The specifications of the functions used in the sample code are listed below.
RX62N Group, RX621 Group RiicIni Overview Header Declaration Description Arguments Return values Notes RIIC Multi-Master Communication RIIC initialization riic.h void RiicIni(uint8_t, uint8_t) Initializes the RIIC module. First argument: uint8_t in_SelfAddr The address of this device itself (The low-order bit must be set to 0.) Second argument: uint8_t in_Enable 0: RIIC communication disabled Any other value: RIIC communication enabled None R01AN0630EJ0100 Rev.1.
RX62N Group, RX621 Group RiicSlvStart Overview Header Declaration Description Arguments Return values Notes RIIC Multi-Master Communication Starts slave mode operation riic.h void RiicSlvStart(uint8_t * , uint8_t * , uint32_t , CallBackFunc, CallBackFunc) Starts slave mode operation. If the slave address matches during slave mode operation, slave transmission or slave reception is started according to the R/W# bit.
RX62N Group, RX621 Group RiicStart Overview Header Declaration Description Arguments Return values RIIC Multi-Master Communication Starts master mode transmission riic.h uint8_t RiicMstStart(uint8_t, uint8_t *, uint32_t, CallBackFunc) Starts master mode transmission. After master mode transmission is started, this function calls the callback function under the following conditions.
RX62N Group, RX621 Group 3.7 3.7.1 RIIC Multi-Master Communication Flowcharts Main Processing Figure 2 shows the flowchart for the main function.
RX62N Group, RX621 Group 3.7.2 RIIC Multi-Master Communication Callback Function (Slave Mode Transmission Complete) Figure 3 shows the flowchart for the callback function (slave mode transmission complete). Callback function (slave mode transmission complete) Start slave mode operation RiicSlvStart() return Figure 3 Callback Function (Slave Mode Transmission Complete) 3.7.
RX62N Group, RX621 Group 3.7.5 RIIC Multi-Master Communication RIIC Initialization Figure 6 shows the flowchart for RIIC initialization.
RX62N Group, RX621 Group 3.7.7 RIIC Multi-Master Communication Start Master Mode Communication Figure 8 shows the flowchart for starting master mode communication. Figure 8 Starting Master Mode Communication 3.7.8 Acquire Master Mode Communication Result Figure 9 shows the flowchart for acquiring the result of master mode communication. Figure 9 Acquiring the Master Mode Communication Result R01AN0630EJ0100 Rev.1.
RX62N Group, RX621 Group 3.7.9 RIIC Multi-Master Communication RDRF Interrupt Handling Figure 10 shows the flowchart for RDRF interrupt handling.
RX62N Group, RX621 Group 3.7.10 RIIC Multi-Master Communication TDRE Interrupt Handling Figure 11 shows the flowchart for TDRE interrupt handling.
RX62N Group, RX621 Group 3.7.11 RIIC Multi-Master Communication TEND Interrupt Handling Figure 12 shows the flowchart for TEND interrupt handling. TEND Interrupt Handler Master mode communication in progress? Yes No Data remaining = 0? (Transmission complete?) No Yes Issuing a stop condition Enable TXI interrupt Disable TEI interrupt Transmit data Data remaining = 0? (Transmission complete?) No Yes Read receive data (dummy read) return Figure 12 TEND Interrupt Handling R01AN0630EJ0100 Rev.1.
RX62N Group, RX621 Group 3.7.12 RIIC Multi-Master Communication Stop Condition Detection Interrupt Handling Figure 13 shows the flowchart for stop condition detection interrupt handling. Figure 13 Stop Condition Detection Interrupt Handling R01AN0630EJ0100 Rev.1.
RX62N Group, RX621 Group 3.7.13 RIIC Multi-Master Communication NACK Interrupt Handling Figure 14 shows the flowchart for NACK interrupt handling. NACK Detection Interrupt Handling Disable TXI interrupt Disable TEI interrupt Master mode communication in progress? No Read receive data (dummy read) Yes Request issuing a stop condition Set the master mode communication result to NACK detected return Figure 14 NACK Interrupt Handling R01AN0630EJ0100 Rev.1.
RX62N Group, RX621 Group 3.7.14 RIIC Multi-Master Communication Arbitration Lost Detection Interrupt Handling Figure 15 shows the flowchart for arbitration lost detection interrupt handling.
RX62N Group, RX621 Group 3.7.15 RIIC Multi-Master Communication Timeout Detection Interrupt Handling Figure 16 shows the flowchart for timeout detection interrupt handling.
RX62N Group, RX621 Group 4. RIIC Multi-Master Communication Sample Code The sample code can be downloaded from the Renesas Electronics Corporation web site. 5. Reference Documents • RX62N Group, RX621 Group User’s Manual: Hardware, Revision 1.11 (The latest version can be downloaded from the Renesas Electronics Web site.) • Technical Updates and Technical Manuals (The latest information can be accessed at the Renesas Electronics Web site.) • RX Family C Compiler Package, Version.1.0.1.
RX62N Group, RX621 Group RIIC Multi-Master Communication Website and Support Renesas Electronics Website http://www.renesas.com/ Inquiries http://www.renesas.com/inquiry All trademarks and registered trademarks are the property of their respective owners. R01AN0630EJ0100 Rev.1.
Revision Record Rev. 1.00 Date Sep.27.
General Precautions in the Handling of MPU/MCU Products The following usage notes are applicable to all MPU/MCU products from Renesas. For detailed usage notes on the products covered by this manual, refer to the relevant sections of the manual. If the descriptions under General Precautions in the Handling of MPU/MCU Products and in the body of the manual differ from each other, the description in the body of the manual takes precedence. 1.
Notice 1. All information included in this document is current as of the date this document is issued. Such information, however, is subject to change without any prior notice. Before purchasing or using any Renesas Electronics products listed herein, please confirm the latest product information with a Renesas Electronics sales office. Also, please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website.