User`s manual

RX62N Group, RX621 Group 5. Usage Examples
5.12. Serial Communication Interface
5.12.1.
SCI Reception
Figure 5-19 shows the setting of SCI channels 0 and 1 and the reception of data using interrupts (channel 0) and
polling (channel 1).
/* 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 prototypes */
void System_failed(void);
void System_reset(void);
void SCI0RxFunc(void);
void SCI0ErrFunc(void);
void System_failed(void);
volatile char rx_string[10];
void main(void)
{
uint8_t result = 0;
/* Initialise 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 0: Async, 8N1, 38400 baud */
R_SCI_Create(
0,
PDL_SCI_ASYNC | PDL_SCI_8N1,
38400,
1
);
/* Set up SCI channel 1: Async, 8N1, 19200 baud */
R_SCI_Create(
1,
PDL_SCI_ASYNC | PDL_SCI_8N1,
19200,
0
);
/* Start the interrupt-based reception of 9 characters on channel 0 */
R_SCI_Receive(
0,
PDL_NO_DATA,
(uint8_t *)rx_string,
9,
SCI0RxFunc,
SCI0ErrFunc
);
R20UT0084EE0112 Rev.1.12 Page 5-35
July. 16, 2014