User`s manual

RX62N Group, RX621 Group 5. Usage Examples
5.6. DMA controller
The following examples show the use of triggers by software, IRQ pin edge detection and SCI transmission.
5.6.1. Software and IRQ triggers
Channel 0 will copy the string "Renesas RX62N" into the destination area when a falling edge occurs on pin
IRQ3-B.
Channel 1 will copy the string "Hello, World" into the destination area as soon as it is enabled.
/* PDL functions and definitions */
#include "r_pdl_dmac.h"
#include "r_pdl_cgc.h"
#include "r_pdl_intc.h"
#include "r_pdl_io_port.h"
/* RPDL device-specific definitions */
#include "r_pdl_definitions.h"
/* Required for this example */
#include <string.h>
/* Callback function prototype */
void DMAC0_transfer_end_handler(void);
/* Data source and destination declarations */
const char source_string_1[]="Renesas RX62N";
const char source_string_2[]="Hello, World";
volatile uint8_t destination_string_1[]=".......................";
volatile uint8_t destination_string_2[]=".......................";
void main(void)
{
uint8_t StatusValue;
uint32_t SourceAddr;
uint32_t DestAddr;
uint16_t TransferCount;
uint16_t SizeCount;
/* 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
);
/* Enable control of LED0 */
R_IO_PORT_Set(
PDL_IO_PORT_0_2,
PDL_IO_PORT_OUTPUT | PDL_IO_PORT_OPEN_DRAIN
);
/* Configure channel 0 */
R_DMAC_Create(
0,
PDL_DMAC_BLOCK | PDL_DMAC_SOURCE_ADDRESS_PLUS | \
PDL_DMAC_DESTINATION_ADDRESS_PLUS | PDL_DMAC_SIZE_8 | PDL_DMAC_IRQ_END,
PDL_DMAC_TRIGGER_IRQ3,
R20UT0084EE0112 Rev.1.12 Page 5-15
July. 16, 2014