ATtiny43U - INT0 ISR being called twice after wakeing

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm putting the micro into power-down sleep mode and using asynchronous pin change interrupt INT0 to wake it up. Its set to trigger an int on rising edge of INT0. When I debug and single step my program in AVR studio it seems to call the ISR for INT0 twice. The first time it executes the ISR but doesn't clear the INTF0 flag. The 2nd time it executes it, it does clear the INTF0 flag. Its not a huge issue but I'm just wondering if this is normal behavior and if I'm doing something wrong.

ISR(INT0_vect){
	external++;
}


Thanks!
for(;;){
		GIMSK |= (1<<INT0); //re-enable INT0 int. 
		sleep_enable();
		sleep_bod_disable();
		sei();
		sleep_cpu();  //cpu goes to bed here!
		sleep_disable();  //CPU wakes up here!
		GIMSK &= ~(1<<INT0); //disable INT0 int for now. 
		if(external!=0){ //if triggered by external 
			//do things!
		}
}

You don't gno-me!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you using real hardware, or a simulator?

If real hardware, buttons bounce. And thus you are seeing the reason that polling/debouncing is used for button/key/switch work.

Use the INT to wake up. But then stay awake and do debouncing and other needed processing before re-sleeping.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahhh your right. I thought while single stepping in AVR studio it would be a null issue. I guess not!

Thanks!

You don't gno-me!