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

Current consumption of if condition in for(;;) loop

Hello,

as I couldn't manage to get my SPI Measurement working flawlessly when called from inside a timer handler I tried to work around it by just setting a flag inside the timer handler and then call the measurement from inside the main()-function in the for(;;)-loop after the power_manage();-function by putting the code inside if(flag) { SPI-Stuff; flag=false; }

int main(void)
{ 

    for (;;)
    {
      power_manage();	
				
			if(test_flag) {
lots of code
				test_flag=false;
			}

    }
}

What is the current consumption of this? In what state is the chip when constantly checking the if flag?

Parents Reply
  • Thanks for your commitment but sadly I already went trough this and similar posts. But I am still wondering how the if statement works in that combination.. Is it handled like a software interrupt: Sleep until the flag has been set (Because the CPU awakes when the timer times out and only then checks the flag again)? Or does the CPU just sits there awake checking the whole time? As its it after the power_manage but gets executed I assume something like the first thing mentioned happens? Is there an easy way to check in which state the chip is?

Children
No Data
Related