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.

Memory overwrite side effect bug

Other Parts Discussed in Thread: MSP430F5342, CC110L

I am using msp430f5342 and I am having an issue that is related to I believe some compiler optimizations that might be happening. I have an array that holds some RF configuration values and the code locates it at address 0x2d84. The definition is as follows:

static registerSetting_t cc110L_radio_settings[]=
{

{CC110L_IOCFG2, 0x2E},
{CC110L_IOCFG1, 0x2E},

.....

};

Another global variable happens to be located at 0x2D84 and is defined as:

uint8_t remote_command_received=0;

The value of this variable is only assigned 0 or 1. However, when the code to set the radio using the above array executes, it changes the value of location 0x2D84 to 0x12. Even when declaring it as volatile, the value still changes to 0x12 which seems bizzare. However, when declaring the radio settings with the const keyword, the problem goes away. I believe in that case the actual reference to the array is stored in the code segment:

static const registerSetting_t cc110L_radio_settings[]

Can someone clarify what might be happening here and what is best practice to avoid it? Thanks.

Fahd