Hello,
I'm trying to store an int in Flash.... and reading it back after switching the device (a MSP430F2274) on.
"int command_time;" - is a global declared integer
"Flash_Settings" is specified in lnk_msp430f2274.cmd as "Flash_Settings = 0x10C0;"
and within the module as "extern volatile char Flash_Settings[2];"
The function to write is:
void settings_to_flash(){
_disable_interrupts();
BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz
DCOCTL = CALDCO_1MHZ;
FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing Generator
FCTL3 = FWKEY + LOCKA; // Clear LOCK & LOCKA bits
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
// write int to Flash
Flash_Settings[0] = (command_time>>8) & 0xFF;
Flash_Settings[1] = command_time & 0xFF;
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCKA + LOCK; // Set LOCK & LOCKA bit
init_dco(); // Set DCO back to working value
_enable_interrupts();
}
when reading back the int I never get the right values....?
Reading is done as:
command_time = Flash_Settings[0];
command_time |= Flash_Settings[1] >> 8;
What am I doing wrong? First I thought my shifting is wrong, but while debugging the values read from Flash are totally incorrect.
Maybe someone can help me out. Thanks,
Mitch
__________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com[Non-text portions of this message have been removed]