Hi,
i noticed during debugging my code that any write to the FCTLx registers has no effect. One exception is the LOCKA bit which can be toggled just fine but for example the LOCK bit always stays 1. The FCTL3 and FCTL1 registers have their reset values of 0x9658 and 0x9600 at the beginning
In my code i set the FCTL3 and FCTL1 registers according to the following lines.
FCTL3 = FWKEY;
FCTL1 = FWKEY + ERASE;
//dummy write to start the erase process
*((u16*)0x8000) = 0;
And according to the assembler code it does exactly what it should do:
mov.w #0xA500,&FCTL3
mov.w #0xA502,&FCTL1
However if i step past each of the instructions then the register then the register values have not changed their value according to the debugger. FCTL3 is still 0x9658 instead of 0x9600 and FCTL1 still has the value 0x9600 instead of 0x9602.
I am using the CC430F6137 and my code is running from flash. My idea was that the LOCK and ERASE bits might be immediatly reset because the next instruction is fetched from flash. According to the example code and datasheet you just have to do a dummy write at a segment in order to start the erase process. However how should this work if the LOCK bit is set and the ERASE bit reset until then? The ACCVIFG Flag is obviously set once the dummy write instruction is executed, however the segment is properly erased.
Thanks for any hints.