cancel
Showing results for 
Search instead for 
Did you mean: 

Memory questions

hervett
Associate II
Posted on May 29, 2009 at 19:43

Memory questions

16 REPLIES 16
hervett
Associate II
Posted on May 17, 2011 at 12:54

OOOKKKK, I understand now !

So i will buy these books !! ^^

So, If I understand, You can't just store variable in flash and write and read it all the time, you have before to erase the bank where is the data and after write it, but I think it's more easy to tell that instead of of do that. SO do you know if someone has already create something on STM32, a procedure like Writevariableinflash ( VariableName )

Read Variableinflash ( VariableName ) ?....It will be easyer for me ...^^

So I will now try to find these books and I hope someone have already do that.

Thank you again, very very much

st3
Associate II
Posted on May 17, 2011 at 12:54

Quote:

So i will buy these books !!

Just buying books will simply deplete your bank balance.

You will need to spend time studying them!

Quote:

SO do you know if someone has already create something on STM32

Yes, there is a whole page full of application notes, examples, etc at

http://www.st.com/mcu/modules.php?name=mcu&file=familiesdocs&FAM=110

I suggest that you take a look at AN2594, ''EEPROM emulation in STM32F101xx and STM32F103xx microcontrollers''...

giles
Associate II
Posted on May 17, 2011 at 12:54

Yes, check the stm32 firmware library and the flash example, theres an example of what you want in there.

with regards ram and flash, in general you program code into flash so it stays there for when you turn the micro on, however as you cant write to it easilly and can only write to it a limited number of times we instead store variables in RAM, this is Fast and can be read and written easily and can be written or read as often as we like - but it's lost when the power goes (this is all true when you're getting started but you'll find exceptions to this when you get used to embedded stuff).

You'll need from st's flash library

FLASH_Unlock

FLASH_ErasePage

FLASH_ProgramWord

to read your word (int or unsigned int)

MyVariable = *((int *)YOURADDRESS;

YOURADDRESS might be something like 0x800C000

which would be the 12th bank of flash in the smaller micros

The firmware libarary is here:

http://www.st.com/stonline/products/support/micro/files/um0427.zip

and the example in 'examples\FLASH\Program' really does everything you want just copy it;)

hervett
Associate II
Posted on May 17, 2011 at 12:54

ok !!

really really thank you I will try that this evening.....and i promise you i will buy them and study study study them !!! :D

I hope that will be OK !!

Thanks a lot for the support and now memories are a little bit clear in my head!!

Thanks again

pranamesh
Associate II
Posted on May 17, 2011 at 12:54

hervett,

I having the same issue of not being able to read the contents properly. could you please share with me your piece of code to resolve this reading from flash

thanks in advance.

hervett
Associate II
Posted on May 17, 2011 at 12:54

I tried to use program code from the application note talking about EEProm emulating, but it don't work. There is an exemple og How write a variable but not for reading a variable,, I've used EE_ReadVariable, but it return me ReadStatus at ''1''. I thought that the exemple will works at the first time but not, I'm trying now to debug and search the problem.

If you have alreay try something with this AN, I want ideas.

Thanks

hervett
Associate II
Posted on May 17, 2011 at 12:54

Hello,

Code with the EEPROM simulating still don't work for me, and so i've decided to take code from the first example of the library FLASH, and it works perfectly, I've created so two procedure named WriteFlash and ReadFlash and so I keep value after my power down .

Really thank you again for your help again