I'm going to have to play with it, because I seem to remember writing an interrupt-driven beeper program that had no busy loop for the blink and buzz class, but now I'm not certain. I had it there at first, but deleted it before I posted this email, thinking that a busy loop was burning processor time that I didnt want to waste for no good reason.
Not really thinking too straight right now. I was so busy on this thing that I hadnt realized that I spent 7 hours on it and hadnt eaten anything in that time.
--
To post to this group, send email to hive76-d...@googlegroups.com
To unsubscribe send email to hive76-discuss...@googlegroups.com
For more awesome goto http://groups.google.com/group/hive76-discussion?hl=en
As long as the chip is running and awake it will be pulling
instructions and executing them, so having a busy loop doesn't burn
any more cycles. The only way to stop it from executing is to
explicitly put the chip to sleep (and set it up to wake up an external
interrupt. The general architecture would be:
void main()
{
hw_init(); /* make sure it's configured to wake up on an external
interrupt */
while(1)
{
goToSleep();
handleWakeupStuff();
}
}
void externalInterruptISR()
{
doInterruptStuff();
}
So when goToSleep() runs, the chip goes to sleep immediately. Then
every time the external interrupt hits, it executes the ISR, then
passes control back to the main loop and executes handleWakeupStuff().
If you're just toggling output pins then you can do that from the ISR,
but if you want to do anything that takes a little longer it's good
practice to defer the work to the main loop and keep the ISR fast.
-s