User`s manual
RX62N Group, RX621 Group 5. Usage Examples
5.6.3. SCI reception trigger
DMAC channel 2 will transfer 5 received characters into the assigned storage area and then call the callback
function.
/* PDL functions and definitions */
#include "r_pdl_dmac.h"
#include "r_pdl_cgc.h"
#include "r_pdl_intc.h"
#include "r_pdl_sci.h"
/* RPDL device-specific definitions */
#include "r_pdl_definitions.h"
/* Callback function prototype */
void DMAC2_transfer_end_handler(void);
/* Data destination area */
volatile uint8_t destination_string_1[]=".......................";
void main(void)
{
/* Initialise the system clocks */
R_CGC_Set(
12.5E6,
100E6,
50E6,
PDL_NO_DATA,
PDL_CGC_BCLK_DISABLE
);
/* Set the CPU’s Interrupt Priority Level to 0 */
R_INTC_Write(
PDL_INTC_REG_IPL,
0
);
/* Configure the RS232 port */
R_SCI_Create(
2,
PDL_SCI_ASYNC | PDL_SCI_TX_DISCONNECTED | PDL_SCI_8N1,
115200,
0
);
/* Configure channel 2 */
R_DMAC_Create(
2,
PDL_DMAC_REPEAT | PDL_DMAC_SOURCE_ADDRESS_FIXED| \
PDL_DMAC_DESTINATION_ADDRESS_PLUS| PDL_DMAC_SIZE_8 | PDL_DMAC_IRQ_END,
PDL_DMAC_TRIGGER_SCI2_RX,
(uint8_t *)&SCI2.RDR,
destination_string_1,
1,
20,
PDL_NO_DATA,
PDL_NO_DATA,
PDL_NO_DATA,
DMAC2_transfer_end_handler,
7
);
/* Enable channel 2 */
R_DMAC_Control(
2,
PDL_DMAC_ENABLE,
PDL_NO_PTR,
R20UT0084EE0112 Rev.1.12 Page 5-21
July. 16, 2014