This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

code execution problem (nrf 51)

I have some very basic code that does not appear to be executing correctly.

There are two versions of code that I would think should have the same result. They do not, and I am trying to figure out why.

Option A:

volatile uint8_t in_pole_flag = 1;    
in_pole_flag = 1;
if(in_pole_flag == 0)    //  <=========== difference point
{
    init_and_loop_funct();
} 

Option B:

volatile uint8_t in_pole_flag = 1;    
in_pole_flag = 0;
if(false)    //  <=========== difference point
{
    init_and_loop_funct();
}

Running the "init_and_loop_funct()" function results in the chip running in a high current mode (many modules initialized and running), while continuing without running the function results in a low current idle mode. Option "A" results in the "init_and_loop_funct()" function executing, while option "B" does not. Why do these two code segments result in different execution?

I would very much like to toggle the execution of the "init_and_loop_funct()" function with a flag, but the above behavior is making this impossible. Any help would be greatly appreciated.

Parents Reply Children
No Data
Related