User`s manual

RX62N Group, RX621 Group 5. Usage Examples
5.14.3. Master mode with DTC
In the following example, data is written to an EEPROM in two bursts. The DTC is used to handle the data
transfer.
The same EEPROM address locations are then read out in two bursts. The DTC is used to handle the data
transfer.
/* Peripheral driver function prototypes */
#include "r_pdl_iic.h"
#include "r_pdl_cgc.h"
#include "r_pdl_cmt.h"
#include "r_pdl_dtc.h"
/* RPDL device-specific definitions */
#include "r_pdl_definitions.h"
static void write_eeprom_data(void);
static void read_eeprom_data(void);
void iic_tx_dtc_end_handler(void);
void iic_rx_dtc_end_handler(void);
#define EEPROM_MEMORY_ADDRESS_UPPER 0x00
#define EEPROM_MEMORY_ADDRESS_LOWER 0x00
#define EEPROM_ADDRESS (0x00A0 | EEPROM_MEMORY_ADDRESS_UPPER)
volatile uint8_t bus_busy;
volatile uint8_t data_storage[20];
/* Reserve an area for the DTC vector table */
#pragma address dtc_vector_table = 0x00001000
uint32_t dtc_vector_table[256];
/* Reserve 16 bytes (full address mode) for the transfer data areas */
uint32_t dtc_iic0_tx_transfer_data[4];
uint32_t dtc_iic0_rx_transfer_data[4];
void main(void)
{
const uint8_t eeprom_data_array_1[] = {EEPROM_MEMORY_ADDRESS_LOWER,
0x01, 0x02, 0x03,
0x04, 0x05};
const
uint8_t eeprom_data_array_2[] = {EEPROM_MEMORY_ADDRESS_LOWER + 5, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
uint8_t i;
/* Configure the clocks */
R_CGC_Set(
12.0E6,
96E6,
48E6,
PDL_NO_DATA,
PDL_CGC_BCLK_DISABLE
);
/* Configure the DTC controller */
R_DTC_Set(
PDL_DTC_ADDRESS_FULL,
dtc_vector_table
);
/* Set up a DTC channel for IIC transmission */
R_DTC_Create(
PDL_DTC_NORMAL | \
PDL_DTC_SOURCE_ADDRESS_PLUS | PDL_DTC_DESTINATION_ADDRESS_FIXED | \
PDL_DTC_SIZE_8 | \
PDL_DTC_IRQ_COMPLETE | \
PDL_DTC_TRIGGER_ICTXI0,
dtc_iic0_tx_transfer_data,
R20UT0084EE0112 Rev.1.12 Page 5-55
July. 16, 2014