Memory Write :
_DINT(); // Disable Interrupt while (BUSY & FCTL3) ; // Check if Flash being used FCTL2 = FWKEY + FSSEL_1 + FN3; // Clk = SMCLK/4 FCTL1 = FWKEY + ERASE; // Set Erase bit FCTL3 = FWKEY; // Clear Lock bit *mem_address = 0; // Dummy write to erase Flash segment while (BUSY & FCTL3) ; // Check if Flash being used FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCK; // Set LOCK bit FCTL2 = FWKEY + FSSEL_1 + FN3; // Clk = SMCLK/4 FCTL3 = FWKEY; // Clear Lock bit FCTL1 = FWKEY + WRT; // Set WRT bit for write operation mem_address = (char *) 0x0E00A; *mem_address = 55; mem_address = (char *) 0x0E00B; *mem_address = temp; // copy value to flash FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCK; // Set LOCK bit _EINT(); // Enable Interrupt
Hello,
I am working on a project, which uses the internal memory storage of the Microcontroller - MSP430G2955. The Main purpose is to store two variable into memory locations. So that If the power failure occurs, the previous status can be retrieved from the memory. For that 55D(37H) is stored in the memory location 0x0E00A & temp variable is stored in memory location 0x0E00B.
The problem is, When I use debugger, It works well but when I use external power supply, it does not work.
For the said problem one can think to review the power supply section, but with the same power supply section and with the same program code the other project works well.
So please suggest me the possible solutions for the said problem.
The memory read program is also shown here.
main()
{
......
......
mem_address = (char *) 0x0E00A;
new_var = eeprom_read();
mem_address = (char *) 0x0E00B;
temp_var = eeprom_read();
......
......
}
unsigned char eeprom_read(void)
{
unsigned char mem_read;
FCTL2 = FWKEY;
FCTL3 = FWKEY;
FCTL1 = FWKEY;
mem_read = *mem_address;
return mem_read;
}