NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Some Interrupt Code
July 15, 2011 by SpaceGhost |
Hello all, I have been playing around with, and trying to learn interrupts. I put together some code based on stuff I seen in some forum examples. What I wanted to do was see if I could was write a program that would "interrupt" another program while it was performing a sequence of events - For example, pushing a button to stop the program in the middle of what it is doing, do something else, and then resume the original program sequence from the point where it had left off... The code I wrote does a "Nightrider" type of LED sequence - a lit LED sequences back and forth through 8 LEDs. When I push the button (PC5) once, the sequence stops immediately, then another LED (not one in the sequence) blinks twice, and then the Nightrider sequence resumes where it had left off.
This is the first interrupt program I have attempted to write. The code works on my MCU. However, one thing concerns me - when I write the code to the MCU, I get
Is this something I need to be concerned about? I'm not sure exactly what this warning is trying to tell me. And, the program does what I want it to do. Could someone offer me some suggestions on how I might clean the code up a bit? Thanks for any advice, Dave |
---|---|
July 15, 2011 by esoderberg |
Dave, Line 162: return 0; You don't need that. Eric |
July 15, 2011 by SpaceGhost |
Hey thanks Eric, I took the return 0; out and it compiled just fine :) . This was my first try at doing an interrupt from scratch - pretty neat how it works. |
January 31, 2012 by tchilzer2 |
Hey SpaceGhost, I just want to say thanks for this code cause I have been trying to figure out these interrupts for about two weeks. this is just the example I needed to make my sensor work! |
Please log in to post a reply.
Did you know that NerdKits make a great parent/child activity? Learn more...
|