So interrupts seem to be a bit simple, yet tricky. I am trying to do something which I am not sure if it is possible.
So I am working with ATTiny85 and trying to use a momentary switch on PB0 (aka PCINT0) to toggle operating modes.
On PB1-PB4 I have a cheap stepper motor that I am writing to looping through states to rotate it.
Now two modes I am trying to work out.
Mode 1: Continous Stepper operation
Mode 2: 10 mins on Stepper, 50 mins sleep.
Idea is using the momentary switch on PCINT0_vect to toggle modes.
Now - the following works in different code setups..
1) use SLEEP_MODE_PWR_DOWN and PB0 to wake ATTiny85 ISR(PCINT0_vect)
2) use SLEEP_MODE_IDLE to put the ATTiny85 to sleep using Timer0 overflows ISR(TIMER0_OVF_vect) and wake up after a duration of time.
Having problem doing the following:
1) Breaking out of continuous Stepper loop with PCINT0_vect -> seems to multi-trigger the interrupt like 4x which flips the mode 4x .
I'm wondering if this is tripping up because I am writing out PORTB for stepper, but also simultaneously using Pin Change Interrupt on PB0
2) Trying to break out of sleep_mode() with PCINT0_vect / Pin change on PB0 -> I'm not sure if this is possible.
I think this is because when it is in sleep_mode using timer0 overflow interrupt .. it just isn't possible to break out with Pin Change Interrupt.
Or maybe simply.. I am doing too much with the same PortB and need to jump up to a bigger AVR. I do have a few ATMega328Ps laying around that I could use too..
idk.. any thoughts here?