Gast
#3162854
Hi,
ich versuche vergeblich im AtmelStudio 6.1 Simulator einen Pinchange
Interrupt auszulösen. Mein code:
#include <avr/io.h>
void powerDown(void){
GIFR |= (1<<PCIF); // Clear eventually occurred previous interrupts
GIMSK |= (1<<PCIE); // Activate Pin change interrupts
PINB |= (1<<PB4);
PINB |= (1<<PB4);
PINB |= (1<<PB4);
GIMSK &= (0<<PCIE); // Deactivate Pin change interrupts
}
ISR(PCINT0_vect) {
PINB |= (1<<PB4);
PINB |= (1<<PB4);
}
int main(void)
{
//SREG &= 0B01111111; //Disables Interrupts globally during setup
PORTB |= (1<<PB0)|(1<<PB1)|(1<<PB2); //Setting outputs to zero,
activating pullups on inputs
DDRB |= (1<<PB3)|(1<<PB4)|(1<<PB5); //0, 1, 2 are inputs, 3, 4, 5 are
outputs
//GIMSK = (1<<PCIE); // Activate Pin change interrupts
PCMSK |= (1<<PCINT0)|(1<<PCINT1)|(1<<PCINT2); // Sets the Pin change
interrupt mask, only PB0,1,2 will trigger the PCINT once it it enabled
before sleep
//MCUCR = (1<<ISC00)|(0<<ISC01);
SREG |= (1<<SREG_I); //Enables Interrupts globally after setup
while(1)
{
//TODO:: Please write your application code
PINB |= (1<<PB4);
powerDown();
}
}
Mit PINB |= (1<<PB4); toggle ich einen Pin, um einfach irgendwas zu
machen ;) powerDown soll später mal Sleep aktivieren und dann soll der
Mikro per Pinchange Interrupt wieder aus dem Schlaf zurück geholt
werden. Sorry für die Wahrscheinlich total einfache Frage, aber ich
fange gerade erst an mit Mikrocontrollern und kenne mich noch nicht gut
aus.
Während der drei
PINB |= (1<<PB4);
PINB |= (1<<PB4);
PINB |= (1<<PB4);
ändere ich manuell den State eines der drei Inputs im single Step Modus,
aber es passiert garnichts und der Code wird weiter normal ausgeführt,
ohne in die ISR zu springen.