Hello,

I use the information-flash to store some ‘constant’ values
The code is based on code form TI.

void Flash_Init(void)
void Flash_WriteByte(char *Data_ptr, char byte)
void Flash_WriteWord(int *Data_ptr, int word)
void Flash_Erase(int *Data_ptr)

int Flash_Copy(int *source_ptr, int *dest_ptr, int size)

I use segment A to store the value and segment B to backup the values if
segment A is updated (copy to B erased A rewrite new data to A)

It is possible that A was erased and then the power is down. So al data is
lost!
No wory just call the function Flash_CheckOnStartUp() a the begin of your
program.
(Is it done in Flash_Init())
It restore segment B is segment A is all erased.

The application uses Flash_WriteInfo(int index, int word) to update the info
flash
and the macros
#define   Flash_ReadInfo(index)        *(int  *) (FSEG_A + (index*2))
#define   Flash_ReadInfoMsb(index)     *(char *) (FSEG_A + (index*2)+1)
#define   Flash_ReadInfoLsb(index)     *(char *) (FSEG_A + (index*2))
To read form flash.

Note that index it between 0 and 63
0<= index<=63

Note that it is posible to write bytes.


Robert Bon


Steve Underwood wrote:

> Daniel Néri wrote:
>
> >Steve Underwood <ste...@coppice.org> writes:
> >
> >
> >
> >>You can't write bytes. You have to write whole 16 bit words.
> >>
> >>
> >
> >Sorry, but this is simply not true. MSP430 flash memory is bit-, byte-
> >and word-programmable.
> >
> >
> Then tell us how. The rest of us only know how to program whole 16 bit
> words, including the chip's designers. Everyone else gets the effect of
> programming a bit or byte in the way I described. You write a whole
> word, where the bit you don't want to change are set to 1.
>
> Regards,
> Steve
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
> Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id78&alloc_id371&opÌk
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Attachment: mspflash.c
Description: application/unknown-content-type-c_auto_file

Attachment: mspflash.h
Description: application/unknown-content-type-h_auto_file

Reply via email to