2019-02-26 09:25 PM
Hi.
I changed the debugging tool from IAR to trueSTUDIO for STM32.
There is code that IAR created and completed the operation. However, the same code, but does not work in trueSTUDIO.
An example of the code is shown below.
int a = 0;
void HAL_TIM_PeriodElapsedCallback (TIM_HandleTypeDef * htim)
{
a ++;
}
void example_function()
{
a = 0;
while (a <3)
{
asm volatile ("NOP");
}
}
int main()
{
example_function();
while(1)
{
}
}
I found the cause with a breakpoint in trueSTUDIO, and I can not get out of the while statement with the code below.
asm volatile ("NOP");
What is the difference between IAR and trueSTUDIO?
What is the solution to this situation?
Solved! Go to Solution.
2019-02-26 10:20 PM
The variable should be declared volatile. The callback is called under interrupt context, outside normal code flow. GNU/GCC is likely optimizing things out because the variable isn't defined/classified properly.
2019-02-26 10:20 PM
The variable should be declared volatile. The callback is called under interrupt context, outside normal code flow. GNU/GCC is likely optimizing things out because the variable isn't defined/classified properly.