Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430



Ads

Discussion Groups

Discussion Groups | MSP430 | Re: Writing an int to Flash

The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.

Re: Writing an int to Flash - old_cow_yellow - Jul 9 19:23:25 2008

You do not need any shifting or masking. In stead of:
Flash_Settings[0] = (command_time>>8) & 0xFF;
Flash_Settings[1] = command_time & 0xFF;
what you really need is:
mov.w &command_time, &0x10C0;

--- In m...@yahoogroups.com, dasGnu wrote:
>
> 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]
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )