Hi, I am working on a project required to erase/write flash memory on Raspberry Pi Pico inside a FreeRTOS task. I know in order to erase/write flash I need to disable interrupt, I tried wrap around flash function with taskENTER_CRITICAL() and taskExit_CRITICAL() but no luck, still freeze when flash erase is call. I removed FreeRTOS and just run the flash code by itself, it works fine. Below is the snippet of the flash function I am using.
uart_puts(UART_ID, "Erase\r"); taskENTER_CRITICAL(); //uint32_t ints = save_and_disable_interrupts(); flash_range_erase(FLASH_TARGET_OFFSET, FLASH_SECTOR_SIZE); //restore_interrupts (ints); taskEXIT_CRITICAL(); uart_puts(UART_ID, "Write\r"); taskENTER_CRITICAL(); //uint32_t ints1 = save_and_disable_interrupts(); flash_range_program(FLASH_TARGET_OFFSET, (uint8_t *)err, FLASH_PAGE_SIZE); //restore_interrupts (ints1); taskEXIT_CRITICAL();
I am wondering if I didn’t disable the interrupt correctly or if there are something to do with FreeRTOS SMP version.