K64F flash: why do I need to disable the system IRQs when writing/erasing sectors on the first bank (0 -> 512KB)?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K64F flash: why do I need to disable the system IRQs when writing/erasing sectors on the first bank (0 -> 512KB)?

533 Views
jorgeramirezort
Contributor I

I noticed that unless I disable interrupts before calling FLASH_erase or FLASH_write for sectors located in the first flash bank (0..512KB) the system reboots continuously. 

This is not required when accessing the second flash bank (512KB to 1024KB).

I am using the KSDK 2.0.

I couldn't find any information in the documents that captures the above observation - and I can't actually make any sense out of it.

Please could anyone shed some light?

many thanks

2 Replies

438 Views
jorgeramirezort
Contributor I

Thanks Mark. Will read the documents again - this time more carefully!

0 Kudos

438 Views
mjbcswitzerland
Specialist V

Hi Jorge

The K64 has two Flash "planes" (2 x 512K blocks). When writing/erasing any part of a block/plane the complete block is not available for program operation until the operation has terminated.

This means that if you have program and interrupt vectors operating exclusively in the first plane (first 512k) addresses/sectors in the second plane (second 512k) can be modified without any restrictions.

If you however modify anything in the first 512k (which has code and interrupt vectors in operation) you must run the flashing routines in RAM (since the program flash is not available) and you also need to disable any interrupt since they will also cause the vectors and interrupt handling code to be executed - causing a failure since the Flash plane cannot be accessed. [An exception would be if the interrupt vectors are in SRAM and also all interrupt handling code are also in SRAM].

If you look carefully you should find a description of the flash being constructed of two planes, which is giving the information about what is possible and what needs to be restricted during flash operations.

Regards

Mark