dear sir,
i write code to receive uart data normally.i get data bytes one by one its working
then i use dma method basis of your sample code but it not works .i write code to receive 4 bytes.but
code stuck at
while( (!(DMA_TCD0_CSR & DMA_CSR_DONE_MASK)) &(!(DMA_ES) ));
when i comment this while i gets value zero only
code
/* Enable the clock to the DMA channel mux */
SIM_SCGC6 |= SIM_SCGC6_DMAMUX0_MASK;
/* Enable the clock to the DMA module */
SIM_SCGC7 |= SIM_SCGC7_DMA_MASK;
DMAMUX0_CHCFG1 |= ( 0 | DMAMUX_CHCFG_ENBL_MASK | DMAMUX_CHCFG_SOURCE(2)); // enable the DMA channel request // UART0-Rx is source 2
/* Configure UART to generate Rx DMA requests */
UART_C2_REG(UART0_BASE_PTR) |= UART_C2_RIE_MASK;
UART_C5_REG(UART0_BASE_PTR) |= UART_C5_RDMAS_MASK;
/* Configure DMA Channel TCD */
DMA_TCD0_SADDR = (uint32) &UART_D_REG(UART0_BASE_PTR); // DMA source is the UART data register
DMA_TCD0_ATTR = ( 0 | DMA_ATTR_SSIZE(0)| DMA_ATTR_DSIZE(0) );
DMA_TCD0_SOFF = 0x0; // don't increment source address
DMA_TCD0_NBYTES_MLNO = 1; // move 1 byte per request
DMA_TCD0_SLAST = 0x0; // no adjust after last transfer
DMA_TCD0_DADDR = (uint32)&packet[0]; // destination is the string variable
DMA_TCD0_CITER_ELINKNO = ( 0 | DMA_CITER_ELINKNO_CITER(4) ); // execute the minor loop strLen times
DMA_TCD0_DOFF = 0x01; // increment dest by 1 after each transfer
DMA_TCD0_DLASTSGA = 0x0; // no adjust after last transfer
DMA_TCD0_BITER_ELINKNO = ( 0 | DMA_BITER_ELINKNO_BITER(4) ); // execute the minor loop strLen times
DMA_TCD0_CSR= ( 0| DMA_CSR_DREQ_MASK );// disable request when the transfer is complete
while(1)
{
/* Wait for DMA to complete or to generate an error */
while( (!(DMA_TCD0_CSR & DMA_CSR_DONE_MASK)) &(!(DMA_ES) ));
for(char j=0;j<4;++j)
printf("%x",packet[j]);
printf("\n\r");
}