simplefoc / Arduino-FOC

Arduino FOC for BLDC and Stepper motors - Arduino Based Field Oriented Control Algorithm Library
https://docs.simplefoc.com
MIT License
2.02k stars 518 forks source link

current sense: RP2040ADCEngine DMA not stopping #259

Closed greymfm closed 11 months ago

greymfm commented 1 year ago

In our controlller we need to temporary stop the RP2040ADCEngine, so we can use RP2040 flash memory access for saving parameters in the user interface.

The RP2040ADCEngine stop function hangs in 'dma_channel_abort': https://github.com/simplefoc/Arduino-FOC/blob/47fc35cfa6dacb1135a7786a5c8ddf160ec5fd29/src/current_sense/hardware_specific/rp2040/rp2040_mcu.cpp#L242

The reason is that DMA_IRQ_0 needs to be disabled first (before any call to 'dma_channel_abort'): irq_set_enabled(DMA_IRQ_0, false);

Then it will no longer hang in RP2040ADCEngine stop :-)

runger1101001 commented 1 year ago

Thank you very much for reporting this! I will see that it gets fixed for the next release...