Usage example (Master, Transmit)

Transmit 4Bytes data by Master.

[GUI setting example]

Serial

Used

IICA0

Used

Transfer mode

Single master

Master0

Clock mode setting

fCLK/2

Local address setting

16

Operation mode setting

Normal

Transfer clock (fSCL)

100000(bps)(Actual value99378.882)

Communication endinterrupt priority (INTIICA0)

High

Master transmission end (Callback function setting)

Used

Master reception end (Callback function setting)

Unused

Master error (Callback function setting)

Unused

Generates stop condition in master transmission/reception end callback function (Callback function enhanced feature setting)

Used

[API setting example]

r_main.c

/* Start user code for pragma. Do not edit comment generated here */

#define SLAVE_ADDR (0xA0) /* slave address */

/* End user code. Do not edit comment generated here */

/* Start user code for global. Do not edit comment generated here */

volatile uint8_t g_iica0_tx_buf[4] = { 'A', 'B', 'C', 'D' };

/* End user code. Do not edit comment generated here */

void main(void)

{

R_MAIN_UserInit();

/* Start user code. Do not edit comment generated here */

/* Start to send data as master mode */

R_IICA0_Master_Send(SLAVE_ADDR, (uint8_t *)g_iica0_tx_buf, 4U, 128U);

while (1U)

{

;

}

/* End user code. Do not edit comment generated here */

}

r_cg_serial_user.c

static void r_iica0_callback_master_sendend(void)

{

SPT0 = 1U;

/* Start user code. Do not edit comment generated here */

/* Stop IICA0 module operation */

R_IICA0_Stop();

/* End user code. Do not edit comment generated here */

}