AnsweredAssumed Answered

DMA_MDATAALIGN_HALFWORD for stm32f407 usart seems not working (porting from stm32f103)

Question asked by moshkin.georgy on Nov 8, 2016
Latest reply on Nov 8, 2016 by moshkin.georgy
I have code which is working on STM32F103:

    hdma_usart1_rx.Instance = DMA1_Channel5;
    hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
    hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
    hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE;
    hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
    hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
    hdma_usart1_rx.Init.Mode = DMA_CIRCULAR;
    hdma_usart1_rx.Init.Priority = DMA_PRIORITY_LOW;

I use HALFWORD to fill TWO bytes in memory if ONE byte is received on USART.
Unused part is automatically filled with zeroes by STM32F103 hardware.
I am doing it for special purpose and it works well.

Now I am porting my code to STM32F407 (usart2, becaue usar1 have capacitor on discovery board). First problem is that i can't choose HALFWORD in CubeMX for f407. There are some dma fifo settings i am not familiar with, not sure I need it.
Here is ported code:
    hdma_usart2_rx.Instance = DMA1_Stream5;
    hdma_usart2_rx.Init.Channel = DMA_CHANNEL_4;
    hdma_usart2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
    hdma_usart2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
    hdma_usart2_rx.Init.MemInc = DMA_MINC_ENABLE;
    hdma_usart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
    hdma_usart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
    hdma_usart2_rx.Init.Mode = DMA_CIRCULAR;
    hdma_usart2_rx.Init.Priority = DMA_PRIORITY_LOW;
    hdma_usart2_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
It behaves not as I expected.