Due to the U.S. Thanksgiving holiday, please expect delayed responses during the week of 11/22.

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.

MSP430F2131: Change Program Counter to run different firmwares from flash memory

Part Number: MSP430F2131

Hello, I’m Daniele Fingolo sfotware developer from SMH Technologies.

We produce and sell a universal programmers for microcontrollers and memories in general.


We have this important customer who wants to program 2 firmwares inside the memory of an MSP430, one for the final application and one for the functional test.

When the board is in the functional test station it should move to the program counter at the beginning of the test firmware code and execute the code. Once the functional test has been completed, the program counter must be replaced so that the firmware of the final application is always executed from here on.


Can you help us on this topic?


From the programming procedures and the various documents, there is no such procedure to change the Program Counter and execute two different firmwares.

What we have understood, however, is that the initial program counter is located in the reset vector, ie the final address of the memory 0xFFFE-0xFFFF. So our idea to change the program counter is to read the last memory sector, save the data in a buffer, delete the sector and rewrite the sector with the program counter you need.


Could this be a possible correct solution?

  • Looking at the MSP430F2131 technical reference manual, section 7 on Flash memory, it appears the reset vector is located in segment 0.  To reprogram that one word location you will need to first copy the contents of segment 0 into RAM, then perform an erase on that segment (a segment is the smallest portion of memory that can be erased), then rewrite the segment with the replacement address for the reset vector.

  • Thank you for the answer!

    I have not yet tried to apply this proposed solution but I believe it is a viable path without problem. But I would like to understand if there is also another way, that is to change the program counter with the debug settings where it is possible to set the PC. So I wanted to understand without necessarily having to write the Program Counter in the last memory location I want if it is possible to modify it in a volatile and non-permanent way and to execute the code present in the main memory using functions presents in slau320ai like "SetPC_430Xv2(unsigned long Addr)".

    Best regards

  • Hi Daniele,

    I'm thinking if you have both the application code, which uses the reset vector at 0xFFFE, and your test code programmed into the device, you can use JTAG to set the PC to start running the functional test code.  When testing is complete, a device reset is all that is needed to run the application code.  You could use JTAG to set PC = 0xFFFE, but your application code would be responsible for cleaning up any peripheral configured during the functional.  A reset does just what it implies.  It resets everything.

  • Hi Daniele,

    It's been a while since we have heard from you, so I'm going to assume you were able to move forward with your project.
    I will mark this posting as RESOLVED, but if this isn’t the case, please click the "This did NOT resolve my issue" button and reply to this thread with more information.
    If this thread is locked, please click the "Ask a related question" button, and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.