Cannot change DMA configuration after first transfer

dmastm32stm32f10x

I'm using a stm32f10x microcontroller and I'm trying to program its DMA module for normal mode transfers.

The first transfer works perfectly, but after it's over, I try to change the source, destination, size, or any other of the other configuration parameters, one of two things happen:

  • Either the flag remains high the entire time and no other transfers occur;
  • Or (happens when I clear the flag), it doesn't matter how many times I write the DMA_Cmd(DMA_Channel1, ENABLE), it doesn't do anything, even though the transfer complete flag is reset;

Any ideas what could be wrong?

PS: I'm using the device's library

Best Answer

Well, there are a couple of solutions for this, basically you need to reconfigure the module and the DMA and make sure that the necessary bits are set, another way is to just DeInit the hardware module (SPI, UART, whatever), DeInit the DMA and finally configure everything like it was the first time