6 Replies Latest reply on Dec 11, 2015 12:28 PM by user_385543602

    Problem Reading UART Data Into DMA

    user_385543602

      See the attached project.

         

      I am trying to read 512 bytes of UART data into a buffer with DMA.  The setup works fine without the DMA - manually transferring the data into the buffer using the 'BREAK' as a signal for a packet start, but the DMA does not transfer any data into the buffer. 

         

      Any ideas of what I did wrong?  This is my first DMA project, any help is appreciated.

         

      Thank you,
      Tom

        • 1. Re: Problem Reading UART Data Into DMA
          user_1377889

          You enabled the buffer for the UART component which will transfer the received data using the internal interrupt from FIFO to buffer. This is the job the DMA should do.

             

          You defined the interrupt to be generated by a break signal it looks a little bit as if you want to transfer all received data after a break. doesn't look as if that won't work, the buffer is an internal circular buffer and you never get to know the current address.

             

          I would suggest to transfer from FIFO byt-by-byte into your receive buffer using the DMA, although doing that using interrupts will be quite sufficient for an UART connection.

             

           

             

          Bob

          • 2. Re: Problem Reading UART Data Into DMA
            user_385543602

            Hi Bob,

               

            Thank you for the response.  I should have explained what I *wanted* to do so you could see what it was versus what I was actually doing.  The data is sent in 512 byte packets.  The break triggers a new packet.  What I wanted to do was after each break, transfer all data from the last packet, and reset the buffer (I did not do this in the code).  Would this work?  

               

            If I do it byte by byte, I will need an ISR from the UART anyway to check if a new packet is coming.  I wanted to automate this within the DMA component.  I should have mentioned, it will not always be 512 bytes, that is a maximum.  

               

            What would be the best way to reset the buffer after the break command?  How do I tell the DMA to reset to the beginning of the buffer for both read and write?

               

            Thank you,
            Tom

            • 3. Re: Problem Reading UART Data Into DMA
              user_1377889

              Try with this settings.

                 

               

                 

              Bob

              • 4. Re: Problem Reading UART Data Into DMA
                user_385543602

                Hi Bob,

                   

                Thanks for the project - I can see a few places where I made mistakes.  I am still getting nothing transferring.  One thing I noticed is that when you turn the UART buffer up over 4 (to 512 in this case) the RX On Byte Received immediately comes on.  My guess is that this is tripping the DMA every time a data element is received, so that the buffer never fills up (because it is cleared each time).  Is there any way to parse between the two interrupt sources before the DMA does its thing?
                Regards,

                   

                Tom

                • 5. Re: Problem Reading UART Data Into DMA
                  user_1377889

                  The DMA runs independent of the CPU, so you may not use any interrupt for the devices. As I told before: why don't you use interrupts instead of DMA? the speed of an UART is so slow, there is time enough to handle > 2000 chracters/s interrupt driven which is ~20,000baud

                     

                   

                     

                  Bob

                  • 6. Re: Problem Reading UART Data Into DMA
                    user_385543602

                    Hi Bob,

                       

                    I do have a solution using the interrupts from the UART component.  I was just investigating DMA as a simpler, behind the scenes way of accomplishing the same thing.  I think I will probably stick with that in this case.

                       

                    Thank you for your help,

                       

                    Tom