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.

Write in Flash Memory

Other Parts Discussed in Thread: TMS570LS3137

I am using the microcontroller TMS570LS3137 and F021 API (version -> 1.51) to perform read and write operations on flash memory. I need to know if there is any mechanism designed to perform a backup of an entire sector in RAM without using more than 2KB of RAM.

The procedure that I am using is as follows:

  1. Read the entire contents of the sector where new data will be stored.
  2. Make a copy of entire contents of the sector, in an array in RAM (which means using up to 128 KB due to the size of the bigger sector).
  3. Array´s contents are updated with the new data.
  4. Finally, entire array contents are stored in Flash memory.

As you can see, I'm using half of RAM memory on TMS570LS3137 (256 KB of RAM), which is not recommended for the design of the application that I'm working.

If there is a procedure to write into a specific Flash memory address without affecting all sector contents, I would appreciate so much if someone can help me, please.

Regards…

  • David,

    First of all, flash memory needs to be erased before programming. The minimum size for erase is a sector. You can find the address and size of Flash memory sectors in the device data sheet. I am attaching an example code for erase and program flash using F021 API. After flash is erased, all you need is the start address of the RAM you want back up, the start address of the Flash memory you want to to program, and the number of bytes you want to backup.

    3884.F021_Program.c

    Thanks and regards,

    Zhaohong

  • Ok Zhaohong, I have already checked literature, and I know Flash memory ranges and sizes.

    I'm sorry, I forgot to indicate that effectively I erase affected sector before write, in fact, the correct sequence is shown below:

    1.- Read the entire contents of the sector where new data will be stored.

    2.- Make a copy of entire contents of the sector, in an array in RAM (which means using up to 128 KB due to the size of the bigger sector).

    3.- Erase sector.

    4.- Array´s contents are updated with the new data.

    5.- Finally, entire array contents are stored in Flash memory.

     

    The problem is that I have data stored in that sector and I want to keep them.

    I only want to modify some sector´s bytes to store new data without losing information already stored.

    I understand your code, but the question is ¿how to back up all sector´s data before to perform write operation?

    This is the reason I looking for a procedure to do it.

    Thank you very much, really.

  • David,

    Assume that you have a sector of 4K bytes. The sector is initially erased. The first time you programmed 512 bytes to back up the RAM content. You can keep programming the rest of the sector without erasing because those flash locations are already erased.

    Thanks and regards,

    Zhaohong