Hi Lukas,
So after your feedback I checked and addressed the BIUCR registers and the memory management unit mapping. It appears that this is what prevented me from erasing flash. I am now able to erase flash after addressing those two areas.
I now have ran into a different issue where after it erases successfully the CPU resets.
FLASH_A.LMLR.R = 0xA1A11111; // unlock flash
FLASH_A.LMLR.R = ~0x00010300;
FLASH_A.SLMLR.R = 0xC3C33333;
FLASH_A.SLMLR.R = ~0x00010300;
FLASH_A.MCR.B.ERS = 1; // set erase
FLASH_A.LMSR.R = 0x00010300; // select blocks
*(uint32_t*)0x20000 = 0xFFFFFFFF; // interlock write <--- erases successfully
FLASH_A.MCR.B.EHV = 1;
while(FLASH_A.MCR.B.DONE == 0); // wait for erase to signal DONE! <-- FAILS here
FLASH_A.MCR.B.EHV = 0;
FLASH_A.MCR.B.ERS = 0;
After looking on the forums I thought this could be watchdog related so I used the following code to try and disable the watchdog:
SWT.SR.R = 0x0000C520;
SWT.SR.R = 0x0000D928;
SWT.MCR.B.WEN = 0;
asm("e_li %r3, 0"); // e200 core watchdog timer
asm("mtspr 340, %r3");
asm("sync");
I used this link as reference:
Do you have any thoughts on what could be related to this new issue? The flash gets erased correctly, but nothing seems to execute after that point.
Thanks,
Victor