Skip to main content
ss2
Associate II
March 19, 2013
Question

Flash Read and Write Problem

  • March 19, 2013
  • 11 replies
  • 3105 views
Posted on March 19, 2013 at 10:40

Hi,

     I want to display 2 parameters(ID and BD) value on seven segment display. The values will be dynamically changed, so every time I want to write these 2 byte of values on FLASH memory and every power ON or System Reset, I want to Read that values from Flash Memory.

    Before writing any values if i read the Flash memory, I'm getting some garbage values. After erasing and writing 2 bytes of values to Flash memory, I am not able to read that again. Can anybody help me....

Thanks

Selva.

#flash-programming #flash-erasing-programming
This topic has been closed for replies.

11 replies

crt2
Visitor II
March 19, 2013
Posted on March 19, 2013 at 11:54

Do you have external flash? Which processor/board are you running?

I think we need some more information if you want a bit more help...

Tesla DeLorean
Guru
March 19, 2013
Posted on March 19, 2013 at 14:48

a) Why would you write to the base of flash where your code and vector table are supposed to reside?

b) Why wouldn't you just read the memory directly, it acts like ALL other memory in read mode? You don't need to unlock it or jump through hoops.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ss2
ss2Author
Associate II
March 19, 2013
Posted on March 19, 2013 at 15:16

Thank U for ur response... will it create any problem, writing to the base of the flash ?

ss2
ss2Author
Associate II
March 19, 2013
Posted on March 19, 2013 at 15:20

Thank U for ur response.... No I'm not using any external flash. may i know the configuration steps for flash read,erase and write..?

Tesla DeLorean
Guru
March 19, 2013
Posted on March 19, 2013 at 17:03

will it create any problem, writing to the base of the flash ?

If you have code there, and expect the processor to start properly, then yes.

Imagine I came to your house, removed the front door, and nailed a bunch of planks and boards over the hole, would it still be usable to access your house? See why this might be a problem for the processor?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ss2
ss2Author
Associate II
March 20, 2013
Posted on March 20, 2013 at 07:56

Thank U for reply..

OK... from which address can i do writing, reading and erasing operation, so that which will properly..

ss2
ss2Author
Associate II
March 20, 2013
Posted on March 20, 2013 at 08:32

Now i have taken the flash memory location as '' 0x0801D000 ''. when i write 2 byte of values to this location, it is going to '' Hard Fault_Handler ''. what should i do, to overcome this problem ? Help me

Thanks....

crt2
Visitor II
March 20, 2013
Posted on March 20, 2013 at 10:41

OK since you dont want to give any information about board and stuff i'll paste you code i have for writting settings to stm32f2 flash

FLASH_Unlock();
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
FLASH_EraseSector(FLASH_Sector_3, VoltageRange_3); 
/* settings at 3*16kB */
int
i;
for
(i=0; i<(
sizeof
(settings)+3)/4; i++)
//I have everything written in settings struct declared elsewhere but you'll get the idea
FLASH_ProgramWord((u32)chip_info.settings+i*4, ((u32*)&settings)[i]);
FLASH_Lock();

Tesla DeLorean
Guru
March 20, 2013
Posted on March 20, 2013 at 12:51

Now i have taken the flash memory location as '' 0x0801D000 ''

Isn't the 64KB flash region 0x08010000 .. 0x0801FFFF ?
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ss2
ss2Author
Associate II
March 21, 2013
Posted on March 21, 2013 at 09:20

Thank u crt..

Actually I'm using stm32f103xx controller....I got it....Thankx again.