Other Parts Discussed in Thread: MSP-FET
Hi Team,
Customer is doing the global variable initialization on MSP430F67771, but find the initialized value of global variable is volatile. The test code is as below:
uint32_t test_value1 = 150;
uint32_t test_value2 = 300;
int main()
{
system_pre_init();
SystemCLK_init(); //configuration to system clock
//ACLK=32.768KHz, MCLK=24.576MHz, SMCLK=12.288MHz
Watchdog_init(); //disable watch dog during firmware initialization
GPIO_init(); //peripheral initialization to GPIO
while(1)
{
if (test_value1 == 150)
{
LED1_ON;
}
else
{
LED1_OFF;
}
if (test_value2 == 300)
{
LED2_ON;
}
else
{
LED2_OFF;
}
LED3_OFF;
__delay_cycles(1000000);
LED3_ON;
__delay_cycles(1000000);
}
}
Customer use LED1 and LED2 to monitor if the global variable test_value1/2 is the value of the initialization 150/300. Then use LED3 to monitor the main() loop.
Problem:
1. When the board is connected with debugger, and debugged in CCS 8.2.0, LED1 and LED2 turn on, LED3 blink. It seems that everything goes well;
2. If disconnect the debugger, and re-power on MCU, sometimes LED1& LED2 turn on, sometimes turn off, but LED3 is blinking. So it seems that the global variable initialization is not correct, and the value of test_value1/2 is random.
After check with customer, the optimization level is 0, even add the 'volatile', the issue is still exist. But if they modify the global variable to local variable, everything seems all right.
So do you have any comments about the issue? Thanks a lot.