Author Topic: how do you enable button on axon to reset using interrupts  (Read 3270 times)

0 Members and 1 Guest are viewing this topic.

Offline yerbieTopic starter

  • Full Member
  • ***
  • Posts: 62
  • Helpful? 3
how do you enable button on axon to reset using interrupts
« 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.

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: how do you enable button on axon to reset using interrupts
« Reply #1 on: January 08, 2009, 11:10:23 AM »
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.
« Last Edit: January 08, 2009, 11:11:48 AM by pomprocker »

Offline yerbieTopic starter

  • Full Member
  • ***
  • Posts: 62
  • Helpful? 3
Re: how do you enable button on axon to reset using interrupts
« Reply #2 on: January 08, 2009, 11:18:02 AM »
thanks.  so I assume that the pin would have to be a pin tied to a supported interrupt like PCINT0?

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: how do you enable button on axon to reset using interrupts
« Reply #3 on: January 08, 2009, 11:22:46 AM »
Do you need to tie a pin to an interrupt?

What are you requirements? What are you trying to accomplish?

Offline yerbieTopic starter

  • Full Member
  • ***
  • Posts: 62
  • Helpful? 3
Re: how do you enable button on axon to reset using interrupts
« Reply #4 on: January 08, 2009, 11:27:05 AM »
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.

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
    • RazorConcepts
Re: how do you enable button on axon to reset using interrupts
« Reply #5 on: January 08, 2009, 04:21:06 PM »
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
Code: [Select]
while(1){
//donothing
}
You could change it to
Code: [Select]
while(!button_pressed){
//donothing
}
rprintf("Button was pressed");

Or something like that. But interrupts would be the better way.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: how do you enable button on axon to reset using interrupts
« Reply #6 on: January 09, 2009, 12:24:49 AM »
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!

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: how do you enable button on axon to reset using interrupts
« Reply #7 on: January 09, 2009, 11:03:09 AM »
nothing wrong with new versions of the axon!

Offline yerbieTopic starter

  • Full Member
  • ***
  • Posts: 62
  • Helpful? 3
Re: how do you enable button on axon to reset using interrupts
« Reply #8 on: January 09, 2009, 11:07:54 AM »
yes, is there a trade-in/upgrade?  :P ;)

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: how do you enable button on axon to reset using interrupts
« Reply #9 on: January 09, 2009, 11:47:06 AM »
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)

 


Get Your Ad Here

data_list