User`s manual

RX62N Group, RX621 Group 5. Usage Examples
5.12.2. SCI Transmission
Figure 5-20 shows the configuration of SCI channels 0 and 1 and the transmission of data (on channel 0) using
polling and then interrupts.
/* 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 SCI0TxFunc(void);
volatile uint8_t result[2];
void main(void)
{
/* Put a null at the end */
result[1] = 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,
7
);
/* Set up SCI channel 1: Async, 8N1, 19200 baud */
R_SCI_Create(
1,
PDL_SCI_ASYNC | PDL_SCI_8N1,
19200,
0
);
/* Wait for 1 character to be received on channel 1 */
R_SCI_Receive(
1,
PDL_NO_DATA,
result,
1,
PDL_NO_FUNC,
PDL_NO_FUNC
);
/* Send a string on channel 0 (wait for completion) */
R_SCI_Send(
0,
PDL_NO_DATA,
R20UT0084EE0112 Rev.1.12 Page 5-37
July. 16, 2014