AnsweredAssumed Answered

STM32F4 modified buffer via DMA and UART is not transmitted correctly

Question asked by Andreas S. on Dec 24, 2016
Latest reply on Dec 24, 2016 by S. Marsanne

Hi all,

I am currenly trying to set up a DMA transfer to UART TX.

I have a buffer
u8 u8ByteBuffer[] = "UART Test...0.";

In DMA-Interrupt (TX complete) I disable DMA with

DMA_Cmd(DMA2_Stream7, DISABLE);
Every 200ms I increment the position '0'
u8ByteBuffer[12] = i;

and enable the DMA again after modify of the buffer.
DMA_Cmd(DMA2_Stream7, ENABLE);

The string is sent via Uart, but the position 12 is in HTerm

some sort of random value and not the incremented value I would

expect, starting at 0x30.

When I step through the code via Keil debugger I see the correctly

incremented values and they are transmitted correctly to HTerm, but only in


Can anyone give me a hint whats going wrong?


Here is my configuration:


DMA_ITConfig(DMA2_Stream7, DMA_IT_TC, ENABLE);
DMA_Cmd(DMA2_Stream7, ENABLE);


void DMA2_Stream7_IRQHandler(void)
  if(DMA_GetITStatus(DMA2_Stream7, DMA_IT_TCIF7) != RESET)
    DMA_ClearITPendingBit(DMA2_Stream7, DMA_IT_TCIF7);


void OnUartDMA(void)
  DMA_Cmd(DMA2_Stream7, DISABLE);


void DMAStream7_Channel4_Init(void)
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);


  DMA_InitTypeDef DMA_InitStruct;
  DMA_InitStruct.DMA_Channel = DMA_Channel_4;
  DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)&(USART1->DR);
  DMA_InitStruct.DMA_Memory0BaseAddr = (uint32_t)&u8ByteBuffer[0];
  DMA_InitStruct.DMA_DIR = DMA_DIR_MemoryToPeripheral;
  DMA_InitStruct.DMA_BufferSize = 14;
  DMA_InitStruct.DMA_Priority = DMA_Priority_Medium;


  DMA_InitStruct.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStruct.DMA_MemoryInc = DMA_MemoryInc_Enable;


  DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  DMA_InitStruct.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;


  DMA_InitStruct.DMA_Mode = DMA_Mode_Normal;
//  DMA_InitStruct.DMA_Mode = DMA_Mode_Circular;


  DMA_InitStruct.DMA_FIFOMode = DMA_FIFOMode_Disable;
  DMA_InitStruct.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;


  DMA_InitStruct.DMA_MemoryBurst = DMA_MemoryBurst_Single;
  DMA_InitStruct.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;


  DMA_Init(DMA2_Stream7, &DMA_InitStruct);
static void USART_Config(void)
  USART_InitTypeDef USART_InitStructure;
  USART_InitStructure.USART_BaudRate = 9600;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
  USART_InitStructure.USART_Parity = USART_Parity_No;
  USART_InitStructure.USART_HardwareFlowControl =
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;


  STM_EVAL_COMInit(COM1, &USART_InitStructure);