Hello,
I am trying to store some data in information flash of MSP430G2353 so I started with erasing the flash. I want to leave segment A alone.
Based on some online tutorials and the family guide I wrote this piece of code to do erase and dump the memory:
#define SEGMENT_D_ADDR 0x1000 #define SEGMENT_C_ADDR 0x1040 #define SEGMENT_B_ADDR 0x1080 #define SEGMENT_A_ADDR 0x10C0 void erase_segment(int *Flash_ptr){ FCTL3 = FWKEY; FCTL2 = FWKEY + FSSEL_1 + 18; //MCLK 8MHz divided by 19 = ~420kHz flash clock FCTL1 = FWKEY + ERASE; *Flash_ptr=0; //trigger erase while (!(FCTL3 & WAIT)){ }//busy wait until erase is complete FCTL1 = FWKEY; //lock the flash back FCTL1 = FWKEY + LOCK; } void dump_segment(int *Flash_ptr){ uart_putc('\n'); uart_putc('\r'); uart_putc('('); for (uint8_t i=0;i<64;i++){ char num = *Flash_ptr; uart_print_hex_8b(num); Flash_ptr++; } uart_putc(')'); }
I use MSPGCC, the MCLK runs at 8MHz from the DCO, UART works fine.
I execute erase_segment(SEGMENT_B_ADDR) (interrupts are disabled) and some time later dump_segment(SEGMENT_B_ADDR).
I get from the UART:
(FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF87FEFFFFFFFFFFFFFFFFFFFFFF100200D7EC7636BF12FEFFFFFFFF017E8877C2)
So the whole segment in only partially erased. Do I need to do more dummy writes? I suspected a broken device so I also tried a different G2353 with similar results.
I'll apreciate your help.