cancel
Showing results for 
Search instead for 
Did you mean: 

ST32F413 undead DMA stream refuses to stop

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;};

4 REPLIES 4

Observe registers. Single step the disasm. Report back.

JW

Danish1
Lead II

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.

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

Danish1
Lead II

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...