build-log
Empty Infinite Loops
We hit a milestone this week - all Arduino code for development of the Voltmeter Clock has been rewritten in lower level C, giving us more control over the peripheral circuits of the microcontroller. The code is now completely interrupt driven, and looks something like this.
int main (void) { mode_pointer = &mode_time;
pwm_init(); timer_init(); analog_init(); pinchange_init(); sei(); // global set enable interrupts
while(1) { //just hang out and wait for interrupts } return 1; }
Note the empty while loop. How does that work? Read on below for the answer.
Interrupt Driven Behavior
The chip is able to enter a powered down mode with the CPU off, while still controlling PWM outputs and running an internal timer. When the timer expires, it powers up the CPU, executes something called an "Interrupt Service Routine," adjusts all the displays and dials, polls to see if the inputs have changed, and returns back to the emptywhile loop.
The code is currently just interrupt driven, the next step is to add the power down instruction to the while loop and see how much power we actually save with a scope. This will drive decisions about battery requirements for the board.
If you'd like to see the full code, in all it's heavily commented glory, check out the Github. (We started with modifying a basic Blinkie program, and the file name is still the same :-). ) Places We Plan on Hanging Out This Week
As part of our ongoing marketing effort, we plan on stopping by at Artisan's Asylum in Somerville, MA at their FREE "Circuit Hacking Night" event this Wed!