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.

CCS/UCD3138: Writing to Data Flash

Part Number: UCD3138

Tool/software: Code Composer Studio

Currently using the code of this URL. http://www.tij.co.jp/tool/jp/ucd3138fw-psfb
I use the code of write_data_flash_word () to write to data flash.  I trying multiple writes to the same location.
however, 0 will always be written on the second  writes. Is there a solution?

  • an expert is looking at this and will get back to you

  • With the data flash, you can only write once.  If you want to write again, you need to erase the entire 32 byte page using the page erase bit in the data flash control register.  There is a software interrupt command for this. All 32 bytes will be converted to FFs.  Of course, you will need to restore all 32 bytes, not just the 4 bytes you are writing to.  If you just do it this way, you can lose your data flash values if there is a power failure during the erase/write process.

    If you look at our EVM codes, you will notice that we have two data flash blocks for calibration and setting data.  We always keep one erased, and one written to.

    When we change data flash values, we write the entire dataset to the erased block.  When it is written and verified, we then start to erase the other block.  That way if there is a power failure, we always have a valid data block.  

    The data flash has additional error correction bits which you can't see, so even just trying to clear a bit isn't reliable.  

    The program flash is designed to be written to twice before the next erase, and it doesn't have any hidden bits, so you can zero out more bits after the first write, which is what we use to clear our checksums.  The only way to set a bit, however, is to erase the program flash page, which is much bigger at 1K bytes.