On Fri, 2003-12-05 at 14:23, D.Pageau wrote:
> I'm looking for example on how to self read/write the 2x 128Bytes
> information memory (flash) with mspgcc
>
> Thanks
>
> --
> Dominic Pageau
Just have a look to the attachment, there is a read_ffs() and a
write_ffs(), simply ignore the data allocation and attempt to the flash
self-programming system initialization.
It works but isn't so beautiful, sorry, but I hope it can help ...
regards
--
Celso Providelo
[email protected]
Linux user #166906
Gwyddion - http://www.gwyddion.com
GNUsp Project
LAMI-Laboratories of Microprocessors
Department of Electrical Engineering
University of Sao Paulo (USP - Sao Carlos)
#include <io.h>
#include <signal.h>
/* write configurations in the internal Flash (256 bytes). */
void write_ffs(void)
{
/* Flash Memory pointer */
int * Flash_int_ptr;
int i;
dint();
/* MCLK/2 for Flash Timing Generator */
FCTL2 = FWKEY + FSSEL0 + FN0;
/* Initialize Flash pointer to Seg B */
Flash_int_ptr = (int *) 0x1000;
/* Set Erase bit */
FCTL1 = FWKEY + ERASE;
/* Clear Lock bit */
FCTL3 = FWKEY;
/* Dummy write to erase Flash segment */
*Flash_int_ptr = 0;
/* Set WRT bit for write operation */
FCTL1 = FWKEY + WRT;
/*FIXME optimize to 8 bits, now is 16. */
for (i=0; i < 4; i++)
{
*Flash_int_ptr++ = (int) pass[i];
}
for (i=0; i < 12; i++)
{
*Flash_int_ptr++ = (int) num_cert[i];
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Reset LOCK bit
eint();
}
/* read the configuration data from internal Flash. */
void read_ffs(void)
{
int * Flash_int_ptr;
int i;
dint();
/* MCLK/2 for Flash Timing Generator */
FCTL2 = FWKEY + FSSEL0 + FN0;
/* Initialize Flash pointer to Seg B */
Flash_int_ptr = (int *) 0x1000;
/* Clear Lock bit */
FCTL3 = FWKEY;
/*FIXME: optimize to 8 bits the same as in write_ffs */
for (i=0; i < 4; i++)
{
pass[i] = (unsigned char) *Flash_int_ptr++;
}
for (i=0; i < 12; i++)
{
num_cert[i] = (unsigned char) *Flash_int_ptr++;
}
FCTL3 = FWKEY + LOCK; // Reset LOCK bit
eint();
}