2009-11-19 09:39 PM
UART and DMA to send data
2011-05-17 04:30 AM
Hi
I just ran an modified USART example DMA_Interrupt from the StdPeriph_Examples. USART1 data sent by DMA and recieved by recieve-interrupt. It works fine the first time. but here's my question: how to trigger/start a DMA transfer again? I tried to disable and enable the DMA channel and DMA-request. Are there any flags to be reset? In comment from the example it says, that the DMA will be triggered by a Tx event. What does that mean? I don't have the TX-interrupt enabled. so how to generate an Tx event? thanks for any help Philipp [ This message was edited by: philipp.hofstetter on 19-11-2009 15:25 ]2011-05-17 04:30 AM
Hi,
A DMA transfer of a single data will start as soon as the the TXE bit is set again. In the Refman TXE bit is set by hardware when the content of the TDR register has been transferred into the shift register. Cheers.2011-05-17 04:30 AM
Hi, thanks for the reply.
Right, TXE shows that TDR is empty. After my DMA transfer to the UART peripheral is complete the TXE is already set. DO I have to reset or set another flag? What I want to do is to initiate another DMA transfer. But not automatically, therefore the DMA-channel is defined as noncircular.2011-05-17 04:30 AM
Hi,
As it's stated in ST documentation: If the channel is configured in noncircular mode, no DMA request is served after the last transfer (that is once the number of data items to be transferred has reached zero). In order to reload a new number of data items to be transferred into the DMA_CNDTRx register, the DMA channel must be disabled. Note that: If a DMA channel is disabled, the DMA registers are not reset. The DMA channel registers(DMA_CCRx, DMA_CPARx and DMA_CMARx) retain the initial values programmed during the channel configuration phase. Hence to to initiate another DMA transfer as you want: -Disable the used DMA channel -Reload the new transfer data size (to so this just the update this field in the ''DMA_InitStructure'', and than update the structure using DMA_Init () function).2011-05-17 04:31 AM
Hi. thanks it works!
I haven't read the manual carefully enough. It works fine to disable the DMA-channel, write the new size to the CNTDR and Enable the DMA channel again. no need to call the whole DMAInit function. I din't made it in that order before:Code:
DMA_Cmd(UART1_Tx_DMA_Channel, DISABLE); UART1_Tx_DMA_Channel->CNDTR = 50; //set the number of data to send DMA_Cmd(UART1_Tx_DMA_Channel, ENABLE);2011-05-17 04:31 AM
Perfect!