Using S32K116, I was trying to program/erase the internal flash. When I step through (step by step), it works perfectly. When I let it run it is halted right after the command sequence right after clearing STAT[CCIF] flag.
This issue was discussed several times, in the community, and the suggested solution was to run this tiny code from RAM. This should involve copying code to the SRAM_L and calling it from flash. However, the RM claims explicitly that code can be run from one section of the flash while another section is programmed/erased.
The code I'm using is as following:
FTFC->FCNFG|= 0x80; /* generate interrupt upon flash's command completion */
} while(!(state & FTFC_FSTAT_CCIF_MASK)) ;
return (u8)(FTFC->FSTAT & 0x71) ;
FTFC->FSTAT= FTFC_FSTAT_CCIF_MASK; /* clr CCIF to start programing */
From RM ( S32K1XXRM, 36.1.2):
Having multiple read partitions allows for concurrent operations such as Read
While Write (RWW)
I have not spent to much time on copying the clr_CCIF() function to SRAM_L, but from little time I tried, it failed.
I will appreciate any help.