The issue of timer interrupt delay caused by filesystem operations

After attempting to write data to the filesystem, my 125μs timer interrupt (highest priority) is delayed by tens to hundreds of microseconds.

I enabled the following configuration and call settings_save_one to save the data.

CONFIG_SETTINGS=y
CONFIG_SETTINGS_NVS=y
CONFIG_NVS=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y

I want the timer interrupt to trigger promptly. Are there any solutions?

  • Hi Lee, 
    What you observed is most likely because of the CPU stalling when doing a write/erase to flash. 
     It takes some time to write a word in flash (~50us AFAIK). So there will be a chance of additional latency when you do flash activity and having a timer interrupt. 

    One solution I can think of is to move your interrupt handler into FLPR core and run it on SRAM. 
    Or you will have to split the critical period that all the flash activity has to wait until the critical period is finished. 

Related