User`s manual

RX62N Group, RX621 Group 5. Usage Examples
1) Configuration and transmission
The MCU’s I²C channel 1 will be configured for Master operation and used to send three bytes to a slave.
Figure 5-26: The bus activity, showing 4 bytes being transmitted to the EEPROM
/* Peripheral driver function prototypes */
#include "r_pdl_iic.h"
#include "r_pdl_cgc.h"
#include "r_pdl_intc.h"
#include "r_pdl_cmt.h"
/* RPDL device-specific definitions */
#include "r_pdl_definitions.h"
#define EEPROM_ADDRESS 0xA0
void main(void)
{
const uint8_t eeprom_data_array_1[5] = {0x00, 0x01, 0x02, 0x03, 0x04};
uint32_t status_flags = 0;
uint16_t TxChars;
uint16_t RxChars;
/* Initialise the system clocks */
R_CGC_Set(
12.0E6,
96E6,
48E6,
PDL_NO_DATA,
PDL_CGC_BCLK_HIGH
);
/* Set the CPU’s Interrupt Priority Level to 0 */
R_INTC_Write(
PDL_INTC_REG_IPL,
0
);
/* Select I²C mode at 100kHz, 300ns rise time, 200ns fall time */
R_IIC_Create(
0,
PDL_IIC_MODE_IIC | PDL_IIC_INT_PCLK_DIV_8,
PDL_NO_DATA,
PDL_NO_DATA,
PDL_NO_DATA,
PDL_NO_DATA,
100E3,
(300 << 16) | 200
);
/* Send the lower address and 3 bytes to the EEPROM, using polling */
S
Slave address
W
A
Memory address
A
Data
A
Data
A
Data
A
P
R20UT0084EE0112 Rev.1.12 Page 5-47
July. 16, 2014