This sample shows how to register a gpio-pin as PowerFail-interrupt and how to store process-data to the XIP-region of flash when this event occurs. It will only work for Trizeps VI RAM-images (nk.nb0), because XIP-images (xip.bin) use the XIP-region to store the OS-image. 1 block = 64 pages, 1 page = 2048 bytes.
Application flow:
Initialize flash.
Get the position of reserved flash region.
Read one block (= 64 pages) and one page and output read performance. ( ~14ms for 1 block, <220us for 1 page)
Ask for new data…
Register interrupt and wait for PowerFail to occur. Which GPIO to use is defined by POWERFAIL_GPIO.
After 10 seconds or after PowerFail-event has occurred wait another 10ms and write one block and one page. ( ~27ms for 1 block, <440us for 1 page).