I am trying to implement a boot loader, that will located on Flash Block 0 and it will receive a SREC file via UART, erase Block 1 and program it with 0x00040000 offset. At the end of these operations, the Boot should to swap between Flash Blocks.
At this stage I am able to erase and program the flash Block 1 with SREC that belong to a simple GPIO example from Kinetis_Eval projects.
In my boot loader code, after the erase/program section I put these commands:
/* enable the clock to SRTC module register space*/
SIM_SCGC6 |= SIM_SCGC6_RTC_MASK;
/* activate swap */
RTC_CCR = 0x1;
When I made a hw reset or wdog reset, MCU jumps to Block 0, and not to Block1.
I use IAR Kickstart 6.2 workbench and MK60N512VLL100 MCU.
Any suggestion on how should I activate the swapping mechanism?