Society of Robots - Robot Forum
Software => Software => Topic started by: yerbie on January 08, 2009, 10:19:41 AM
-
I've been reading through the axon datasheet and the button is currently tied to Pin G5 (OC0B). Is there a way to enable an interrupt so that when Pin G5 changes, then the system would do something like reset or pause?
I looked at the mega640 datasheet and noticed that only certain pins are tied to the PCINT# & INT# interrupt signals.
-
I don't own an Axon myself, but if you connect a N.O. button to any pin (not sure if a pull-up resistor matters or not), and when that button is closed and tied to ground (brought low), then you can either put the MCU in sleep mode, or you can start the watch dog timer which will reset the MCU. This can be implemented in your code.
-
thanks. so I assume that the pin would have to be a pin tied to a supported interrupt like PCINT0?
-
Do you need to tie a pin to an interrupt?
What are you requirements? What are you trying to accomplish?
-
I guess i might be confused. the axon currently has a button, which is tied to Pin G5. I wanted to be notified when that button is pressed. I figured the only way to be notified would be to enable a interrupt so that when the pin changes, then it would call my ISR routine.
my code is basically just using the PWM timers running a couple servos and have an infinite while loop doing nothing, but when the button is pressed, I want to print out a message or do something.
-
I'm sure you can do it with interrupts, but another way might be to change the while loop... since the while loop is an infinite one
while(1){
//donothing
}
You could change it to
while(!button_pressed){
//donothing
}
rprintf("Button was pressed");
Or something like that. But interrupts would be the better way.
-
Sorry, but no hardware interrupts on the button pin. :-\
To be honest, if I were to redesign the Axon all over again, the button would definitely be on an interrupt pin!
-
nothing wrong with new versions of the axon!
-
yes, is there a trade-in/upgrade? :P ;)
-
yes, is there a trade-in/upgrade? :P ;)
don't hold your breath ;)
(any new product I make will be secret till I'm finishing up the final prototypes hehe)