I am developing a system based on the MKW21D256 that implements a certain standard that requires pretty accurate baud rate, to achieve this I have implemented a timer that triggers an interrupt and there I toggle the correct pins etc.
My problem is when I would like to upgrade the system, at the beginning of the operation I want to erase the internal storage flash block (~96kB).
The problem is that it takes a lot of time to format this section and it is being done while under disabling all interrupts.
I tried splitting the erase of the entire block to smaller erases but each one is >5ms long and my timer interrupt interval is every 3.5ms.
Any idea how I can format the flash region without hurting the timing of the system? I want to be able to upgrade the device while still "In service" in terms of the protocol I am implementing.