I have a project which, to save on battery, is put to sleep until an interrupt pin is rising from LOW to HIGH.
This works well on Arduino Nano, however the translation doesn't on the ATTiny.
#include <avr/sleep.h>
void setup(){
pinMode(2,INPUT);
noInterrupts();
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
attachInterrupt(INT0,wakeUp,RISING);
//Yadada
Interrupts();
}
void wakeUp(){
//Something Something
sleep_mode();
}
Both on the Arduino Nano and the AtTiny, the interrupt Pin 0 is equivalent to Pin 2.
- The Arduino is set to ISP
- I have run the Bootloader (with internal clock as 8MHz if that makes a difference)
- The program loads on the AtTiny45.
Yet, the interrupt pin does not interrupt.
Does the INT0 act differently on a ATTiny than on the Arduino, and if so, how can I wake up my AtTiny?
1 Answer 1
After going through a lot of documentation, it seemed best and more efficient to attach the interrupt without functions.
EIMSK |= (1<< INT0);//Attaches the interrupt
MCUCR |= (1<< SM1) //Power-down mode
| (1<<ISC01) //The rising edge of INT0
| (1<<ISC00);// generates an interrupt request
-
I think it's great that you came back and answered your own question. But, this answer seems weirdly mismatched with the question "Does the INT0 act differently on a ATTiny than on the Arduino, and if so, how can I wake up my AtTiny?"timemage– timemage2021年01月13日 14:43:52 +00:00Commented Jan 13, 2021 at 14:43
attachInterrupt(digitalPinToInterrupt(pin), ...