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/MSP430I2041: Msp430 i2041 cannot write to flash

Part Number: MSP430I2041
Other Parts Discussed in Thread: MSP430I2040

Tool/software: Code Composer Studio

Hi.

I try to use TI example at

 http://dev.ti.com/tirex/explore/node?node=AH1usbSuYSeImpZGDdBbhA__IOGqZri__LATEST

 and 

http://dev.ti.com/tirex/explore/node?node=AGy3iy0wxZhiie8W7f-xBw__IOGqZri__LATEST

but cannot write any thing to flash.

In the example, write to flash at 0x1060, but program cannot write to this address, if I change to wirte to RAM, it's ok.

 I see all example not erase the flash segment before write, is it true?

Anyone help me solve this problem.

I only use TI example, not modify any thing!

  • Hey Huy,

    I don't have the board set up right now to test, but I'm fairly certain I have recently tested the first example you linked and it was working for me.    How are you check the flash at 0x1060, did you look at it with the Memory viewer?  

    As for erasing, you are correct that this example doesn't erase the segment.   It is writing to the info memory which contains device critical TLV calibration data.  Without this data, the device is basically useless, so all software project actually check that it's still intact.  If it's missing, then none of our example project will boot.  

    You can still erase this section if you like, but you have to take extra care in your project to preserve and re-write the TLV data back to where it belongs.  

    I was recently working on a MSP430I2040 reference design that was storing Calibration data in the info memory.  I'll try and share with you my example project.  Based on my testing it is successfully saving TLV, erasing the section, and writing a large amount of data.  But, no guarantee that the code is perfect and it may be possible to still brick the device, but it definitely erases and writes flash.  

    I'll find it and share it.  

    Thanks,

    JD

  • Hey Huy,

    Here is that project that I was recently working on developing. MSP430I2040_Calibration_Data_Loader.zip

    Take a look and let me know if it helps.  

    Thanks,

    JD

  • Thanks ,

    I use debug to check flash data after write. You can see I write 0xAA to address 0x1060 but the data get back always 0x00. 

  • Hey Huy,

    You can also look at the memory directly.  If you go to View - Memory Browser.  There you can just input the address 0x1060 and see all the flash bytes. 

    Let me know if you get it working with the example I shared.  

    Thanks,

    JD

  • Hi, There is the memory browser I captured. It shows 0x00 value at 0x1060 in memory.

    Note : I debug on the TI Example code to debug the simple program first, not in your code.

  • Writing flash can't write 1s, it can only change 1s to 0s. Once a flash byte is all 0s it will stay that way until you erase it. 

    As JD pointed out, erasing the Information Segment is hazardous, and needs to be done carefully. Thus there are limitations to anything a self-contained Example can show you.

    It looks as though you have succeeded in writing to flash (since it's 0s now). What is your longer-term goal?

  • As you mentioned, the TI example won't work properly and need add some things to work,  like add delete before writing.

    Is the TI example too obscure for everyone starting with the MSP430i? If "erasing the Information Segment is hazardous, and needs to be done carefully", the example can be try to Read, Write, Erase on others memory location to show full step for writing to flash.

    I wonder that TI did not try to run the example before its release. 

  • Maybe. I would say that the Example is limited in what it can actually show you. It does (evidently) write to flash, which is what it claims. Other flash-write Examples have different hazards -- one I recall would wear out your flash if you left it running for a few minutes.

    I think JD offered you an alternative Example. Did you look at that?

  • Thanks .

    I try the JD offered and it's working properly.

    My application is an energy measurement and it will write some values to flash when it finds an interrupt on AC current

  • Hey Huy,

    Glad to hear that it's working. 

    I want to point out that my example still is not completely fool-proof.  There is a small-time window between erasing the info-memory and writing the TLV data back to Flash that the device is vulnerable.  If a reset/power cycle happens at this point, the calibration data can be lost and render the MSP430I20xx useless.  

    You will see I added a 2-3 second delay at the start of the program, and that is because without it when I went to reprogram the device the timing between power and reset from the JTAG/SBW programmer was exactly hitting this window and bricked some devices.  So, I added a delay as a quick work around.   

    Maybe in the future, I can continue to improve it and find a way to protect against power, reset, or programming interruptions. 

    Thanks,

    JD

**Attention** This is a public forum