User`s manual

RX62N Group, RX621 Group 5. Usage Examples
5.12.3. Synchronous Transmission and Reception
Figure 5-21 shows the configuration of SCI channel 3 as the clock master followed by the simultaneous
transmission and reception of data.
The Receive function call uses interrupts while the Transmit function uses polling.
/* Peripheral driver function prototypes */
#include "r_pdl_sci.h"
#include "r_pdl_cgc.h"
#include "r_pdl_intc.h"
/* RPDL device-specific definitions */
#include "r_pdl_definitions.h"
/* Callback function prototype */
void SCI3RxFunc(void);
volatile uint8_t data_received;
#define BUFFER_SIZE 10
void main(void)
{
uint8_t Tx_Data[BUFFER_SIZE];
uint8_t Rx_Data[BUFFER_SIZE];
uint16_t transfer_size = 8;
uint8_t i;
/* Configure the system clocks */
R_CGC_Set(
12E6,
96E6,
48E6,
0,
PDL_CGC_BCLK_DISABLE
);
/* Set the CPU’s Interrupt Priority Level to 0 */
R_INTC_Write(
PDL_INTC_REG_IPL,
0
);
/* Set up SCI channel 3: Sync, MSb first, 2 Mbps */
R_SCI_Create(
3,
PDL_SCI_SYNC | PDL_SCI_MSB_FIRST,
2E6,
1
);
/* Load the required data into the transmit buffer */
for (i = 0; i < BUFFER_SIZE; i++)
{
Tx_Data[i] = (uint8_t)(i + 1);
}
data_received = false;
/* Set up the receive process (no bus activity will occur) */
R_SCI_Receive(
3,
PDL_NO_DATA,
Rx_Data,
transfer_size,
SCI3RxFunc,
PDL_NO_FUNC
R20UT0084EE0112 Rev.1.12 Page 5-39
July. 16, 2014