Question
UART Tx DMA variable length
Posted on November 25, 2015 at 03:39
I am currently using STM32F4 Discovery board, and i configure UART 2 into DMA mode for sending data.
i am able to send data with a fixed length to UART 2 using DMA. But, i want to send data with a variable length. Example 1:Buffer = ''hello world!''
2: Buffer = ''is this working again?'' 3: Buffer = ''i want to use dma tx mode'' I could do that by reconfiguring the DMA_Init, each before I send the data as shown belowDMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)Buffer;
DMA_InitStructure.DMA_BufferSize = (uint16_t)strlen(Buffer); DMA_Init(DMA1_Stream5, &DMA_InitStructure); Is this the right way to do it? But, i read from the document, whenever I init the DMA, it will take sometime and there is a possibility that I could corrupt the previous DMA transfer. May i know how to a proper way?