AnsweredAssumed Answered

ISR for DMA Transfer of UART data

Question asked by Dan Wermers on Oct 21, 2011
Latest reply on Apr 19, 2012 by TomE



I'm trying to get DMA Channel 0 to transfer 16 bytes from the UART 0 Receive channel to memory.  The configuration of the DMA is in the attached file (view using WordPad).  The UART is working fine.  DMA transfer is **almost** working fine.  I connect my UART channel to a PC running Windows Hyperterminal.  


I then manually type in characters, and have the CPU spit out the characters to UART 0 Transmit (also going to Hyperterminal).  I've created a **mock** DMA Channel 0 ISR (below code).  This is behavior I notice:


When the DMA Channel is initialized or re-enabled with the below **mock** ISR, it will always immediately transfer 1 byte from the UART to memory, regardless of whether the UART actually sent any data.  It works as normal for the other 15 bytes.  So the question is, why does the DMA spit out this first erroneous byte of data?      


   // Mock DMA Channel 0 finished ISR

   // Check DONE bit in DSRn

   if(MCF_DMA_DSR(0) & 0x01)


     // Configure DMAREQ Register to disable DMA Channel 0


     // Clear DSRn Register with DONE bit logic 1

       MCF_DMA_DSR(0) = 0x01;

     // Clear UART errors with UCRn Register

       MCF_UART_UCR(0) = 0x40;

     // Place absolute memory address (destination address) into DARn Register

       MCF_DMA_DAR(0) = (unsigned long int) &UART0_rxd[0];

       // Place number of bytes to transfer into BCRn Register

       MCF_DMA_BCR(0) = DMA_BYTE_count[0];

     // Configure DMAREQ Register to enable DMA Channel 0

       MCF_SCM_DMAREQC |= 0x00000008;

     // Restart DMA channel with START bit logic 1 in DCRn Register

      MCF_DMA_DCR(0) |= 0x00010000;



Why does this **always** spit out an erroneous first byte?