raspberrypi / pico-examples

BSD 3-Clause "New" or "Revised" License
2.83k stars 820 forks source link

Enhance flash SSI DMA example with interrupt control for stable operations #490

Closed francdoc closed 2 months ago

francdoc commented 5 months ago

Description:

This PR introduces interrupt handling in the flash_ssi_dma example to enhance the stability of flash operations on the Raspberry Pi Pico.

Based on insights from Kevin Boone's article (https://kevinboone.me/picoflash.html) and flash.h notes on stable flash memory usage, the updated code now disables interrupts during flash operations. Preventing conflicts especially with USB operations that could otherwise cause the program to hang.

Changes made:

Added save_and_disable_interrupts() and restore_interrupts() around the flash operation block to prevent execution interruptions during flash memory access.

peterharperuk commented 5 months ago

The change makes sense - see comments about sdio uage

francdoc commented 4 months ago

Sure, on it!

francdoc commented 4 months ago

Hi @peterharperuk, I've corrected the stdio issue. It's now configured to rely on user input via the cmake command line.

francdoc commented 3 months ago

Hi @peterharperuk, I believe I made the changes you requested.