How do I know which flash page to erase to subsequently write to it?

I have been asked to write an application to be able to change some variables during runtime and be able to store them in non-volatile memory (flash). I read the C8051f507 datasheet and the process to erase and write to flash looks really straightforward. My question is: How do I know which page to erase?

Thanks for your time,

Fer

Parents
  • Well - sometime you are going to make a decision where to store your variables that you want to be able to modify. When you have decided on which page to store these variables, you will also know which page to erase to modify them.

    You obviously either have to set up the project so the linker places the variables at the decided flash page. Or you have to instead make use of a pointer to as struct and just initialize the pointer to the address of the page.

    Just remember one thing - what happens if the power is lost or something else happens when you erase that page? Is it bad if you lose the values of these variables?

Reply
  • Well - sometime you are going to make a decision where to store your variables that you want to be able to modify. When you have decided on which page to store these variables, you will also know which page to erase to modify them.

    You obviously either have to set up the project so the linker places the variables at the decided flash page. Or you have to instead make use of a pointer to as struct and just initialize the pointer to the address of the page.

    Just remember one thing - what happens if the power is lost or something else happens when you erase that page? Is it bad if you lose the values of these variables?

Children
More questions in this forum