ERASING CODE:
FLASH_A.LMLR.R = FLASH_LMLR_PASSWORD; //unlock register
FLASH_A.LMLR.R = 0x000303FF; //unlock shadow flash
FLASH_A.SLMLR.R = FLASH_SLMLR_PASSWORD; //unlock register
FLASH_A.SLMLR.R = 0x000303FF; //unlock shadow flash
//erase shadow flash
FLASH_A.MCR.B.ERS = 1;
*(unsigned int*)0x00FFC000 = 0xFFFFFFFF; //interlock write - write any address in shadow block
FLASH_A.MCR.B.EHV = 1;
while(FLASH_A.MCR.B.DONE == 0){};
FLASH_A.MCR.B.EHV = 0;
FLASH_A.MCR.B.ERS = 0;
(below is code to set censor password etc, this part is not executed because above hangs)
ISSUE:
this code hangs, code below above block is not executed, after reset i see that shadow is erased, but for some reason erasing procedure hangs, any ideas why?
TEST1:
removed line: while(FLASH_A.MCR.B.DONE == 0){};
result: shadow erased and code hangs
TEST2:
removed line: *(unsigned int*)0x00FFC000 = 0xFFFFFFFF;
result: shadow is NOT erased but NO code hanging, normal execution is proceed
REMARK:
also L0, L1,L2 and L3 has the same behavior, erasing procedure hangs...
the rest of sectors i men L4 to L9, M0,M2, H0 to H5 goes normally.
L0, L1,L2,L3 belongs to partiton 1, this is something common.
I am booting from L0 and then jump to RAM from where executing erasing.
any ides what is wrong? suppose its not problem of code itself, is trivial...hw configuration?