ADuCM320 Hardware Reference Manual
UG-498
Rev. C | Page 139 of 196
desc.ctrlcfg.bits.r_power = 0;
Desc.ctrlCfg.Bits.src_prot_ctrl = 0x0;
Desc.ctrlCfg.Bits.dst_prot_ctrl = 0x0;
Desc.ctrlCfg.Bits.src_size = DMA_SIZE_BYTE;
Desc.ctrlCfg.Bits.dst_size = DMA_SIZE_BYTE;
// Rx primary descriptor
Desc.srcEndPtr = (unsigned int)(&pADI_UART->COMRX);
Desc.destEndPtr = (unsigned int)(puc (iNumVals - 0x1));
Desc.ctrlCfg.Bits.n_minus_1 = iNumRX - 0x1;
Desc.ctrlCfg.Bits.src_inc = DMA_SRCINC_NO;
Desc.ctrlCfg.Bits.dst_inc = DMA_DSTINC_BYTE;
*Dma_GetDescriptor(UARTRX_C) = Desc;
}
// UART DMA Rx IRQ handler
void DMA_UART_RX_Int_Handler()
{
NVIC_DisableIRQ(DMA_UART_RX_IRQn);
// Clear interrupt source
}
Example Code to Set Up UART Transmit DMA Channel
void UARTTXDMAINIT(void)
{
NVIC_EnableIRQ(DMA_UART_TX_IRQn);
// UART Tx DMA interrupt sources
pADI_UART->COMLCR = COMLCR_WLS COMLCR_STOP;
// 8 data bits + 1 stop bit
pADI_UART->COMDIV = 0x41;
// Set UART baud rate
pADI_UART->COMFBR = COMFBR_FBEN_EN | 0x803;
// DIVM = 1, DIVN = 3
pADI_GP1->GPCON = 0x5;
// Configure P1.0/P1.1 for UART
Dma_Init();
pADI_DMA->DMACFG = 0x1;
// Enable DMA mode in DMA controller
UARTDMAWRITE(uxUARTTXData, 16);
pADI_DMA->DMAENSET = 0x10;
// Enable UART_TX_DMA channel
pADI_UART->COMIEN = 0x10;
// Enable DMA Tx transfers
}
void UARTDMAWRITE(unsigned char *pucTX_DMA, unsigned int iNumVals)
{
DmaDesc Desc;
// Common configuration of all the descriptors used here
Desc.ctrlCfg.Bits.cycle_ctrl = DMA_BASIC;
Desc.ctrlCfg.Bits.next_useburst = 0x0;
Desc.ctrlCfg.Bits.r_power = 0;
Desc.ctrlCfg.Bits.src_prot_ctrl = 0x0;
Desc.ctrlCfg.Bits.dst_prot_ctrl = 0x0;
Desc.ctrlCfg.Bits.src_size = DMA_SIZE_BYTE;
Desc.ctrlCfg.Bits.dst_size = DMA_SIZE_BYTE;
// Tx primary descriptor
Desc.srcEndPtr = (unsigned int)(puc (iNumVals - 0x1));