Tool/software:
Hi,
I am currently working with the MSP430F5438A controller. During runtime, a variable is not updating as expected. However, if I place a breakpoint or add a small delay inside the function, the code works correctly. I am trying to understand why this is happening.
I have attached my code scenario, which runs inside a GPIO interrupt.
In the example below, the variable "ok" is not updating in real-time. Ideally, when the code executes, "ok" should be set to 1, but instead, it remains 0, which turns on LED2. In this condition, a load is being switched as per the schematic.

Example Code:
uint8_t ok = 0;
if (P1IFG & BIT2)
{
P11OUT |= BIT2; /*PROC_FAN */
ok = 1;
if (ok == 0)
{
P10OUT |= BIT3; /* LED 2 ON */
}
P1IFG &= ~BIT2;
}
I would appreciate any insights into why this issue occurs and how to resolve it.
Thanks & Regards,
Anbu.