AnsweredAssumed Answered

Issue in Erasing flash for MC9S0SG16

Question asked by girichavana on Apr 15, 2013
Latest reply on Apr 17, 2013 by girichavana

Hi,

 

I have implemented the flash erase routine in C to erase the 3 pages of flash form 0xFA00 tp 0xFFFF. The routine is erasing the First page only (i.e the page 0xFA00). If i keep the brake point at the last line of the erase routine, then i am able to erase the three pages. But with out brake point i am unable to erase all the three pages. below is the algorithm of main and erase routines.

 

Main routine:

1. Load FCDIV for to set the clock 200KHz

2. Disable interrupts

3. Call the Erase routine to erase the page starting at 0xFA00

4. Call the Erase routine to erase the page starting at 0xFC00

5. Call the Erase routine to erase the page starting at 0xFE00

 

Erase Routine:

1.Wait for last Command to complete

2. Load FSTAT to clear the error flags

3. Load the address in page with dummy data

4. Set FCBEF

5. Check FSTAT for errors

6. Wait for FSTAT_FCCF for command completion

 

The main and erase routines are running in the flash starting from location 0xC000.

I am using CodeWarrior for MCU Version: 10.1

Outcomes