I am trying to implement a couple of C functions to erase an information segment on the MSP430F148 and then write selected words to memory, using the assembly example in the user manual as a guide. The system is resetting, and I am not sure where it is happening. I would appreciate any guidance you can give. The MCLK, set to 2 MHZ, is selected for the flash clock source, divided by 5 to give ~400 KHz clock. EE is defined as a pointer to defined structure at location 0x1000 [ EE = (ESeg_Type *) 0x1000 ]. function to erase one information segment_n. ... _DINT( ); WDTCTL = 0x5A80; // WR_WD | HOLDWD; FCTL2 = 0xA544; // (FLWRITE | CLOCKFLASH); FCTL3 = 0xA500; // FLWRITE; // clear lock bit FCTL1 = 0xA502; // (FLWRITE | ERASESEG); EE->SEG[segment_n].SegWords[1] = CLEAR_SEG_CODE; /* dummy write */ /* CPU activities are suspended until the erasure is complete since erasure was called from flash-resident program */ FCTL3 = 0xA510; // (FLWRITE | LOCKBIT); WDTCTL = 0x5A0C; // WR_WD | RESETWD | WD_USES_ACLK_FULL; _EINT(); ... function to store a word of information into segment_n at index position provided. ... _DINT( ); WDTCTL = 0x5A80; // WR_WD | HOLDWD; FCTL2 = 0xA544; // (FLWRITE | CLOCKFLASH); FCTL3 = 0xA500; // FLWRITE; /* clear lock bit */ FCTL1 = 0xA502; // (FLWRITE | WRTBIT); EE->SEG[segment_n].SegWords[index] = wordvalue; /* CPU activities are suspended until the store to flash is complete */ FCTL1 = 0xA500; // FLWRITE; /* clear the write bit */ FCTL3 = 0xA510; // (FLWRITE | LOCKBIT); WDTCTL = 0x5A0C; // WR_WD | RESETWD | WD_USES_ACLK_FULL; _EINT(); ... -- JoAnne Powers No trees were harmed in the transmission of this message; however, a large number of electrons were temporarily inconvenienced. They who will give up essential liberty to obtain temporary safety deserve neither liberty nor safety. -- Benjamin Franklin
Erase and write to info seg of flash from flash resident program
Started by ●April 26, 2003
Reply by ●April 26, 20032003-04-26
Sounds like a watchdog problem, unless of course your program is loaded at address 0x1000? --- In msp430@msp4..., JoAnne.Powers@i... wrote: > I am trying to implement a couple of C functions to erase an information > segment on the MSP430F148 and then write selected words to memory, using > the assembly example in the user manual as a guide. The system is > resetting, and I am not sure where it is happening. I would appreciate > any guidance you can give. > > > The MCLK, set to 2 MHZ, is selected for the flash clock source, divided by > 5 to give ~400 KHz clock. EE is defined as a pointer to defined structure > at location 0x1000 [ EE = (ESeg_Type *) 0x1000 ]. > > function to erase one information segment_n. > ... > _DINT( ); > WDTCTL = 0x5A80; // WR_WD | HOLDWD; > > FCTL2 = 0xA544; // (FLWRITE | CLOCKFLASH); > FCTL3 = 0xA500; // FLWRITE; // clear lock bit > FCTL1 = 0xA502; // (FLWRITE | ERASESEG); > > EE->SEG[segment_n].SegWords[1] = CLEAR_SEG_CODE; /* dummy write */ > > /* CPU activities are suspended until the erasure is complete since > erasure was called from flash-resident program */ > > FCTL3 = 0xA510; // (FLWRITE | LOCKBIT); > > > WDTCTL = 0x5A0C; // WR_WD | RESETWD | WD_USES_ACLK_FULL; > > _EINT(); > ... > > > function to store a word of information into segment_n at index position > provided. > ... > _DINT( ); > WDTCTL = 0x5A80; // WR_WD | HOLDWD; > > FCTL2 = 0xA544; // (FLWRITE | CLOCKFLASH); > FCTL3 = 0xA500; // FLWRITE; /* clear lock bit > */ > FCTL1 = 0xA502; // (FLWRITE | WRTBIT); > > EE->SEG[segment_n].SegWords[index] = wordvalue; > > /* CPU activities are suspended until the store to flash is complete > */ > > FCTL1 = 0xA500; // FLWRITE; /* clear the write > bit */ > FCTL3 = 0xA510; // (FLWRITE | LOCKBIT); > > WDTCTL = 0x5A0C; // WR_WD | RESETWD | WD_USES_ACLK_FULL; > > _EINT(); > ... > > > -- JoAnne Powers > No trees were harmed in the transmission of this message; > however, a large number of electrons were temporarily inconvenienced. > > They who will give up essential liberty to obtain temporary safety deserve > neither liberty nor safety. -- Benjamin Franklin > >
Reply by ●April 26, 20032003-04-26
It can't be the watchdog, because I get the same result if I comment out the reset of the watchdog (leave it off after I enter the program). Thanks for your reply, though. -- JoAnne Powers No trees were harmed in the transmission of this message; however, a large number of electrons were temporarily inconvenienced. They who will give up essential liberty to obtain temporary safety deserve neither liberty nor safety. -- Benjamin Franklin "michelqv" <michel@mich...> 04/26/2003 01:59 PM Please respond to msp430 To: msp430@msp4... cc: Subject: [msp430] Re: Erase and write to info seg of flash from flash resident program Sounds like a watchdog problem, unless of course your program is loaded at address 0x1000? --- In msp430@msp4..., JoAnne.Powers@i... wrote: > I am trying to implement a couple of C functions to erase an information > segment on the MSP430F148 and then write selected words to memory, using > the assembly example in the user manual as a guide. The system is > resetting, and I am not sure where it is happening. I would appreciate > any guidance you can give. > > > The MCLK, set to 2 MHZ, is selected for the flash clock source, divided by > 5 to give ~400 KHz clock. EE is defined as a pointer to defined structure > at location 0x1000 [ EE = (ESeg_Type *) 0x1000 ]. > > function to erase one information segment_n. > ... > _DINT( ); > WDTCTL = 0x5A80; // WR_WD | HOLDWD; > > FCTL2 = 0xA544; // (FLWRITE | CLOCKFLASH); > FCTL3 = 0xA500; // FLWRITE; // clear lock bit > FCTL1 = 0xA502; // (FLWRITE | ERASESEG); > > EE->SEG[segment_n].SegWords[1] = CLEAR_SEG_CODE; /* dummy write */ > > /* CPU activities are suspended until the erasure is complete since > erasure was called from flash-resident program */ > > FCTL3 = 0xA510; // (FLWRITE | LOCKBIT); > > > WDTCTL = 0x5A0C; // WR_WD | RESETWD | WD_USES_ACLK_FULL; > > _EINT(); > ... > > > function to store a word of information into segment_n at index position > provided. > ... > _DINT( ); > WDTCTL = 0x5A80; // WR_WD | HOLDWD; > > FCTL2 = 0xA544; // (FLWRITE | CLOCKFLASH); > FCTL3 = 0xA500; // FLWRITE; /* clear lock bit > */ > FCTL1 = 0xA502; // (FLWRITE | WRTBIT); > > EE->SEG[segment_n].SegWords[index] = wordvalue; > > /* CPU activities are suspended until the store to flash is complete > */ > > FCTL1 = 0xA500; // FLWRITE; /* clear the write > bit */ > FCTL3 = 0xA510; // (FLWRITE | LOCKBIT); > > WDTCTL = 0x5A0C; // WR_WD | RESETWD | WD_USES_ACLK_FULL; > > _EINT(); > ... > > > -- JoAnne Powers > No trees were harmed in the transmission of this message; > however, a large number of electrons were temporarily inconvenienced. > > They who will give up essential liberty to obtain temporary safety deserve > neither liberty nor safety. -- Benjamin Franklin > > . ">http://docs.yahoo.com/info/terms/
Reply by ●April 28, 20032003-04-28
I have written some general purpose flash routines in C and just uploaded them to the file area (flash_c_msp430). You might want to look at them or use them as they are. -Jean- ---------------------- Can spy? CANeye! http://randhahn.de