User`s manual

RX62N Group, RX621 Group 5. Usage Examples
5.12.4. SCI Reception in Asynchronous Multi-Processor mode
Figure 5-22 shows the setting of SCI channel 2 and the Multi-Processor mode reception of data using interrupts
and polling.
/* PDL functions */
#include "r_pdl_sci.h"
#include "r_pdl_cgc.h"
#include "r_pdl_io_port.h"
/* PDL device-specific definitions */
#include "r_pdl_definitions.h"
void SCI1rx(void);
void SCI1Er(void);
#define NUM_DATA 50
volatile uint8_t data_received;
volatile uint8_t error_happen;
volatile uint8_t receive_data[NUM_DATA];
void main(void)
{
uint8_t i;
bool id_received;
for (i=0; i<NUM_DATA; i++)
{
receive_data[i] = 0;
}
/* Configure the clocks */
R_CGC_Set(
12E6,
96E6,
48E6,
0,
PDL_CGC_BCLK_HIGH
);
/* Configure the pin selection of SCI */
R_SCI_Set(PDL_SCI_PIN_SCI2_A);
/* Configure the RS232 port, specify Async MP mode */
R_SCI_Create(
2,
PDL_SCI_8N1 | PDL_SCI_ASYNC_MP,
100E3,
15
);
/* -------------------------------------------- */
/* Async MP mode, data Reception, by CPU ISR */
/* -------------------------------------------- */
data_received = false;
error_happen = false;
/* Wait by CPU ISR, until receive matching Station ID (0x0A) */
R_SCI_Receive(
2,
0x0A00 | PDL_SCI_MP_ID_CYCLE,
PDL_NO_PTR,
0,
SCI1rx,
SCI1Er
);
R20UT0084EE0112 Rev.1.12 Page 5-41
July. 16, 2014