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.

MSP430FR2355: Continue to struggle with persistent data????

Part Number: MSP430FR2355


I have the following code: (I have been here before and even copied from other working code but to no avail???)

#pragma LOCATION (pwmDiv, 0x1800);
#pragma PERSISTENT(pwmDiv);
__vo uint16_t pwmDiv = 50;

#pragma LOCATION (dutyCycle, 0x1802);
#pragma PERSISTENT(dutyCycle);
__vo uint16_t dutyCycle = 31;

#pragma LOCATION (dac_value, 0x1804);
#pragma PERSISTENT(dac_value);
__vo uint16_t dac_value = 2750;

#pragma DATA_SECTION(fw_version, ".info");
const char fw_version[] = {"SWSF-SS_A"};

My .cmd file shows INFO at 0x1800 and

.info : type = NOINIT{} > INFO

The first three variables above are modifiable from user input on running code while fw_version is not.  I am having 2 problems:

1.  After successful writes to the space I reflash code to see if it is retained and it reverts back to the default.  I have tried :  Erase and download necessary segments only; Replace written memory locations..... ; and Erase main memory only under the Flash Settings in CCS...What should I do??

2.  When I look at memory browser in the CCS debugger I see my variable names for the modifiable ones but no where can I find NOR search for fw_version??  It doesn't show up

Can someone please answer these two questions?

Thanks

  • Testing out in a blank project, it appears the variable is getting optimized away even with optimization turned off in the Project Properties. Using the 'volatile' keyword also has no effect. If the variable is not referenced anywhere, the compiler is not going to put it into the output image.

    As a proof of concept, simply assigning a single char value from the fw_version variable is enough to put the const char fw_version into the INFO segment.Successful Compilation into INFO memory segment

    It response to your first question, you may need to set your Erase Options to "By Address Range" and specify an absolute address range to erase.

  • I will use your idea on the fw_version but I can tell you I copied that from another large project that I did and never once called the variable .....there must be a setting somewhere that I am missing ....OR the compiler changed on me

  • Your questions are not clear.

    I don't recognize the __vo specifier. What is that for...volatile?

    The second question seems to be saying that fw_version is not being stored. Is that right?

    Here's what I notice about your array:

    • I would also specify the array fw_version as volatile.
    • The array also does not have a size. Give it a size.
    • The initial value of SWSF-SS_A is string which is larger than a char. Use a larger data type specifier.
    • Unless you are under some type of requirement, I would use a variable of an appropriate data type instead of an array for storing the version number.
    • It also seems that there is no intention for changing the firmware version, since the const specifier is used, so that would be another reason not to use an array.

**Attention** This is a public forum