cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to Flash Memory

mangesh
Associate II
Posted on July 14, 2003 at 21:07

Writing to Flash Memory

2 REPLIES 2
mangesh
Associate II
Posted on May 17, 2011 at 11:54

Hi,

I have an application which performs the following steps:

1. Boot from secondary flash (mapped as csboot0-csboot3:0x0000-0x7FFF)

2. Write to main flash (mapped from fs0-fs3:0x0000-0xFFFF page 0,

and fs4-fs7:0x0000-0xFFFF, page 1) configured as data memory at boot up.

3. Make main flash as program space.

4. Start execution in main flash and make secondary flash as data space.

5. Write/save data to secondary flash.

I do not have any problems with steps 1, 2, 3, 4. However I do not have write access to the main flash executing from the secondary flash even though it is setup to be in data space. If csboot0-csboot3 is mapped at a starting address other than 0x0000 then I am able to perform step #5.

Environment is uPSD3233B, PSDSoft Express, Keil C compiler/linker.

Any pointers to how to resolve this without changing the desired memory map will be greatly appreciated.

Thanks!
joseph2399
Associate II
Posted on May 17, 2011 at 11:54

When writing to a Flash sector, either in Main Flash or Boot Flash, make sure you send the unlock command sequence to the correct address. For example to program a Flash byte, you need write an 0xAAh to address 0xX555h during the first cycle; then write a 0x55 to 0xXAAA during the second cycle etc. The X can be set to any value if you memory segment is mapped to 0 – 0xFFFF. However, if the memory segment is mapped to 0x8000 – 0xFFFF, then X needs to be set to any number between 0x8 and 0xF. Or if your memory segment is mapped to 0x4000 - 0x7FFF, then X must be set to any number between 4 and 7 etc. Note, only address bits A0-A11 are used for instruction decoding; and the X is used for chip select to the Flash sector to write to.