Hi guys, I'm trying to record user button pushes to INFO Flash with the saveProgram() routine below. The first time the routine is called it works fine. The second time the routine is called it does not rewrite the locations. In fact, in some of the locations it writes in a zero. Stepping through the statements I can't find why it would do that, all the necessary registers seem to be ready with the write values. DUring debugging when I removed the line where I set the Flash pointer to 0x1000 (to see if it would at least append) the values do indeed append. Anyone seen something like this? Thanks! -Adeel void saveProgram(void) { unsigned int i=0; FCTL3 ^= (FXKEY + LOCK); // unlock flash to write FCTL1 ^= (FXKEY + WRT); // enable write to flash Flash_ptr = (char *) 0x1000; // initialize flash pointer to first flash address for (i=0; i<64; i++) { *(Flash_ptr++) = eventMem[i]; while ((FCTL3 & WAIT) != WAIT); } FCTL3 ^= (FXKEY + LOCK); // lock flash to write FCTL1 ^= (FXKEY + WRT); // disable write to flash }
Problem rewriting previous locations in FLASH?
Started by ●September 19, 2004
Reply by ●September 19, 20042004-09-19
You've not erased the flash before rewriting it, methinks.
Also, if you've not done that, have you also not set FCTL2 to get the
right timing for the FTG?
-- Paul.
> -----Original Message-----
> From: Adeel [mailto:a2ahmad@a2ah...]
> Sent: 19 September 2004 19:27
> To: msp430@msp4...
> Subject: [msp430] Problem rewriting previous locations in FLASH?
>
>
> Hi guys,
> I'm trying to record user button pushes to INFO Flash with the
> saveProgram() routine below. The first time the routine is
> called it works fine. The second time the routine is called
> it does not rewrite the locations. In fact, in some of the
> locations it writes in a zero.
> Stepping through the statements I can't find why it would do
> that, all the necessary registers seem to be ready with the
> write values. DUring debugging when I removed the line where
> I set the Flash pointer to 0x1000 (to see if it would at
> least append) the values do indeed append. Anyone seen
> something like this? Thanks!
>
> -Adeel
>
> void saveProgram(void)
> {
> unsigned int i=0;
>
> FCTL3 ^= (FXKEY + LOCK); // unlock flash to write
> FCTL1 ^= (FXKEY + WRT); // enable write to flash
>
> Flash_ptr = (char *) 0x1000; // initialize flash pointer to
> first flash address
> for (i=0; i<64; i++)
> {
> *(Flash_ptr++) = eventMem[i];
> while ((FCTL3 & WAIT) != WAIT);
> }
> FCTL3 ^= (FXKEY + LOCK); // lock flash to write
> FCTL1 ^= (FXKEY + WRT); // disable write to flash }
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> $9.95 domain names from Yahoo!. Register anything.
> http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/CFFolB/TM
> --------------------------
> ------~->
>
> .
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
Reply by ●September 19, 20042004-09-19
You're right I did not erase the flash after the initial write... I thought unlocking and enabling write would be enough. I will look into that. I did not set the source clock myself because I actually wanted to use ACLK (00). I need to change that? Thanks much Paul. Cheers... --- In msp430@msp4..., "Paul Curtis" <plc@r...> wrote: > You've not erased the flash before rewriting it, methinks. > > Also, if you've not done that, have you also not set FCTL2 to get the > right timing for the FTG? > > -- Paul. > > > -----Original Message----- > > From: Adeel [mailto:a2ahmad@y...] > > Sent: 19 September 2004 19:27 > > To: msp430@msp4... > > Subject: [msp430] Problem rewriting previous locations in FLASH? > > > > > > Hi guys, > > I'm trying to record user button pushes to INFO Flash with the > > saveProgram() routine below. The first time the routine is > > called it works fine. The second time the routine is called > > it does not rewrite the locations. In fact, in some of the > > locations it writes in a zero. > > Stepping through the statements I can't find why it would do > > that, all the necessary registers seem to be ready with the > > write values. DUring debugging when I removed the line where > > I set the Flash pointer to 0x1000 (to see if it would at > > least append) the values do indeed append. Anyone seen > > something like this? Thanks! > > > > -Adeel > > > > void saveProgram(void) > > { > > unsigned int i=0; > > > > FCTL3 ^= (FXKEY + LOCK); // unlock flash to write > > FCTL1 ^= (FXKEY + WRT); // enable write to flash > > > > Flash_ptr = (char *) 0x1000; // initialize flash pointer to > > first flash address > > for (i=0; i<64; i++) > > { > > *(Flash_ptr++) = eventMem[i]; > > while ((FCTL3 & WAIT) != WAIT); > > } > > FCTL3 ^= (FXKEY + LOCK); // lock flash to write > > FCTL1 ^= (FXKEY + WRT); // disable write to flash } > > > > > > > > > > ------------------------ Yahoo! Groups Sponsor > > --------------------~--> > > $9.95 domain names from Yahoo!. Register anything. > > http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/CFFolB/TM > > -------------------------- > > ------~-> > > > > . > > > > > > Yahoo! Groups Links > > > > > > > > > > > > > > > > > >