Microchip® Advanced Software Framework

Quick Start Guide for PDC - Basic

This is the quickstart guide for SAM3A/3N/3S/3U/3X/4E/4N/4S/G Peripheral DMA Controller (PDC) Driver with step-by-step instructions on how to configure and use the driver.

A handler is required for the interrupt, below is a simple example:

void console_uart_irq_handler(void)
{
/* Get UART status and check if PDC receive buffer is full */
if ((uart_get_status(CONSOLE_UART) & UART_SR_RXBUFF) == UART_SR_RXBUFF) {
/* Configure PDC for data transfer (RX and TX) */
pdc_rx_init(g_p_uart_pdc, &g_pdc_uart_packet, NULL);
pdc_tx_init(g_p_uart_pdc, &g_pdc_uart_packet, NULL);
}
}

First initialise the board:

Now setup the PDC registers:

/* Get pointer to UART PDC register base */
/* Initialize PDC data packet for transfer */
g_pdc_uart_packet.ul_addr = (uint32_t) g_uc_pdc_buffer;
g_pdc_uart_packet.ul_size = BUFFER_SIZE;
/* Configure PDC for data receive */
pdc_rx_init(g_p_uart_pdc, &g_pdc_uart_packet, NULL);
/* Enable PDC transfers */
pdc_enable_transfer(g_p_uart_pdc, PERIPH_PTCR_RXTEN | PERIPH_PTCR_TXTEN);

Enable UART IRQ:

Enable UART interrupt

NVIC_EnableIRQ(CONSOLE_UART_IRQn);

Once the required number of bytes have been transferred, an interrupt is triggered and the handler will run. The main program may execute other code or be busy-waiting:

while (1) {
}