cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 USART1 DMA -> clear DMA content

dominik
Senior
Posted on July 10, 2014 at 11:19

Hi

I configured the USART1 with the DMA Controller to receive 16 Bytes. In case if I receive just 1 Byte (Error on the line for example or when starting the sytem) then I like to delete the whole content of the DMA Controller because otherwise the next correct 16Bytes are shiftet by this ErrorByte and in the target Register there is the ErrorByte and the 15 first Bytes of the correct message. So how can I delete the Buffer of the DMA in case of receiving less than 16 Bytes?

The configuration is added as attachment.

Thanks a lot.

Best Regards, Dominik

#usart1-dma-rx
3 REPLIES 3
Posted on July 10, 2014 at 11:58

Stop and restart the given DMA stream.

JW
dominik
Senior
Posted on July 10, 2014 at 13:11

Hi

With this 2 Commands in the IRQ Handler it doesn't works:

void USART1_IRQHandler(void)

{

    if (USART_GetITStatus(USART1, USART_IT_IDLE) != RESET)

        {

        USART_ClearITPendingBit(USART1, USART_IT_IDLE);

        DMA_Cmd(DMA2_Stream5, DISABLE);    //RX enable    -> receive

        DMA_Cmd(DMA2_Stream5, ENABLE);    //RX enable    -> receive

        }

}

It works but just the 2nd time. This means:

1. 16Bytes, Receive ok

2. 1 Byte _> disable enable

3. 16 Bytes -> doesn't works

4. 16 Bytes -> receive ok

Why do I need to send it after disable/enable 2 times?

Regards

Posted on July 10, 2014 at 14:01

I don't use the ''library'' so can't comment on that code.

The procedure to suspend/resume and to restart a DMA transfer is described in details in RM0090 rev 7, ch.10.3.14 and 10.3.17.

JW