This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Erasing custom sections of FLASH MSP430F5528



Hello everybody!

I would like to know if it is possible to erase a section of Flash created by me. I am not sure if that is possible but if I am wrong I would be grateful to know it. I need to do that as the only way I found to write variables, that are constantly changing during the execution of the program, is to first erase an INFO segment and then writing into it. Due to this I have the big drawback that if I want to save a new variable, the rest of variables that were previously saved are erased.

Please tell me if there is a better way to reach my purpose.

Thank you very much for your attention!

Best Regards,

Dani. 

  • You can use segment erase for non info flash, to increase the re-writable memory size. Algorithm must erase segment only once, and than store variables inside erased buffer until buffer is full. Storing same variable every time on new address / position. More buffers can be used to have lite switching between last / first position.

    Repeatedly erasing / writing only one value at the same address is a wrong way for sure.

  • Thanks for replying. Sorry, I am not an expert on msp430 so I didn't understand quite well what you have explained. The only way I found to write more than one variable in the same segment is creating an array that stores all the desired variables. and then i erase only one time for writing the actualized array. The problem of this way is that memory space is not optimized as i would be able to only write one array for each INFO segment.

    Is it possible to create a custom FLASH segment of i.e. 8 bytes and then only erasing that 8 bytes??
  • Let say that you want to save 4 words, and that this 4 words value will be different from 0FFFFh for sure.

    Reading at start up will search for last valid value, from first info segment address. It will go until word is different than 0FFFFh value, and than read 4 last words.

    Writing will search from first info segment address for 4 words with 0FFFFh value. If this 4 words exists write will store new 4 words, if there is no 0FFFFh words, it will switch to next erased info segment, store new words. Later previous info segment can be erased, if stored values are not used anymore.

    There is no possibility for erasing only few flash bytes/words.

**Attention** This is a public forum