pico-examples icon indicating copy to clipboard operation
pico-examples copied to clipboard

Issue in flash_program.c example

Open lautisilber opened this issue 1 year ago • 3 comments

The functions flash_range_erase and flash_range_program are run without being surrounded by a

uint32_t interrupts = save_and_disable_interrupts();

...

restore_interrupts(interrupts);

block and in my tests, the program crashes without these.

(I'm sorry. This is my first time rising an issue. If this behaviour is excepted or my testing is wrong, sorry for the inconvenience)

lautisilber avatar Aug 08 '24 22:08 lautisilber

You are correct that if the processor is likely to run any code from flash when calling these functions, then they will cause a crash. However this program isn't doing anything else and so doesn't crash. Did you really reproduce a crash running this example?! Anyway - I will improve the example with some comments so anyone copying the code is aware of the problem.

peterharperuk avatar Sep 03 '24 13:09 peterharperuk

The demo run just fine. Only when I tried to copy paste it into a larger project it crashed without those lines. Sorry for the inconvenience and thank you for listening :)

Edit: The new demo is super clean!

lautisilber avatar Sep 03 '24 15:09 lautisilber

I think you're right that we should fix the example to show the proper way to do things. So I've reopened the issue and I'll update the example

peterharperuk avatar Sep 03 '24 16:09 peterharperuk

merged into develop

kilograham avatar Nov 22 '24 19:11 kilograham