Skip to main content
Dave Nadler
Senior III
November 14, 2019
Question

ST32F413 undead DMA stream refuses to stop

  • November 14, 2019
  • 3 replies
  • 703 views

I have a hang on the line below; the DMA stream seems unwilling to stop.

Anybody seen this behavior before? Any work-around?

Thanks!

Best Regards, Dave

while(DMA2_Stream6->CR & DMA_SxCR_EN) {DMA2_Stream6->CR &= ~DMA_SxCR_EN;};

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
November 14, 2019

Observe registers. Single step the disasm. Report back.

JW

Danish1
Lead III
November 15, 2019

Do you have an interrupt-handler for errors (or anything else) on that DMA?

On some stm32 I have seen the act of turning off a DMA-enable would trigger an error on that DMA. This would shoot you off to your interrupt handler - and your code in there might explicitly re-enable the DMA.

Dave Nadler
Senior III
November 15, 2019

No interrupts for the DMA were pending when this happened (including error interrupts)...

Danish1
Lead III
November 17, 2019

Do you mean that none were pending before the start of the while statement?

If so, you misunderstand my comment.

On some stm32, the act of clearing the enable can cause an error interrupt.

So (not having seen your code) executing DMA2_Stream6->CR &= ~DMA_SxCR_EN; might cause the interrupt-handler to be called. And if your interrupt handler sets DMA_SxCR_EN then it will be back on when you test it again. So you go round the loop again and clear the EN bit. And an interrupt is triggered. And the interrupt-handler sets the EN bit...