2015-12-03 05:38 AM
I will be receiving 10 bytes on UART RX periodically and I want to configure UART RX DMA for it.
Configuring DMA is like loading the NDTR register with the number of bytes to transfer from/to peripheral to/from memory. So if I want to configure DMA for UART do I have to initialize DMA controller in each DMA periodic transacation of 10 bytes ? #stm32 #dma2015-12-03 07:42 AM
Well you're going to have to configure enough of it to restart the transfer.
Rx is always an issue because you have to deal with data loss or resync issues. Consider a circular buffer of 20 and interrupt on the HT/TC, and fish out what you need, for the more simplistic approach.2015-12-03 08:20 AM
Hi arbitrer,
Using the DMA circular mode, you should be able to automatically initialize NDTR content without reconfiguring the DMA.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2015-12-03 11:34 PM
Hi
I reffered circular mode code from [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/UART%20with%20DMA%20mode&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=16364]this post and I changed the Buffer size to 10 from 32, but when I'm transferring 10bytes to STM32 I'm not getting Transfer Complete consistently every time. Is it because of the DMA_SxNDTR = Multiple of ((Mburst beat) × (Msize)/(Psize)) inconsistency When I checked MBURST, MSIZE, and PSIZE all are configured for byte, so it should give me DMA_TC on reception of every 10 byte . What am I missing?2015-12-04 12:28 AM
>What am I missing?
Most probably one or more characters. That's why DMA is inappropriate for occasional, non-permanent transmissions. If you miss one character in a packet, the first character of the nect packet will trigger the transfer. That gets you out of sync, and introduces a substantial delay. Use the RXNE interrupt of the UART, this is much more appropriate for your case. And always assume that characters might get lost, or corrupted.
2015-12-04 02:52 AM
But If I'm following Clive's code blindly, ie; 32byte buffer, on every transaction I'm getting the TC flag, So if it was byte missing/corruption it should reflect here also and I don't expect that