2

I'm working with energia for the launchpad 430 and have a rather specific question to make: is example A the equivalent in power consumption has example B, or is it that B drains more power? Thank you.

EXAMPLE A:

void setup() {
  boolean flag = false;
}
void loop() {
  flag = true;
}

EXAMPLE B:

void setup() {
  boolean flag = false;
}
void loop() {
  flag = !flag;
}
Rui Lima
  • 679
  • 2
  • 11
  • 23

1 Answers1

5

Assuming its not optimized, Example A loops flag = 1. Example B on the other hand, toggles every time. Flag = 0, Then Flag = 1, repeat. Based on that, Example B will have more instructions, as it takes the value of flag, inverts it and updates flag. More instructions, more processing time, more power. But since your entire code is a loop without any low-power mode, they will take the same amount of power. Example B just takes a little bit longer, but we are talking fractions of a second.

Passerby
  • 72,580
  • 7
  • 90
  • 202