Atmega168 and peripheral interrupts

I have a problem with an atmega168.

On my test board I have a jumper on PB1 and a LED on PD5, using internal 8MHz RC-clock.

Given the following program: #include #include #include

INTERRUPT(SIG_PCINT0) { unsigned short i; char j;

for(j=0; j

Reply to
P.Marek
Loading thread data ...

I found the problem. I had a wrong signal name - which meant that each interrupt lead to a reset.

Here's the working program. #include #include #include #include

// PD5=OC0B=T1 SIGNAL(SIG_PIN_CHANGE0) { PORTD ^= _BV(PD5); }

int main(void) { // ENable int sei();

/* INITIALIZE 8MHz/256 -> 31 250 Hz */ CLKPR=_BV(CLKPCE); CLKPR=_BV(CLKPS3);

/* enable PD5 as output */ DDRD|= _BV(PD5);

//PCINT1 erlauben PCMSK0=_BV(PCINT1); PCICR=_BV(PCIE0);

//Pull-Up DDRB=0; PORTB=_BV(PORTB1);

/* BLINK, BLINK ... */ while (1) { sleep_mode(); } }

Reply to
P.Marek

I found the problem. I had a wrong signal name - which meant that each interrupt lead to a reset.

Here's the working program. #include #include #include #include

// PD5=OC0B=T1 SIGNAL(SIG_PIN_CHANGE0) { PORTD ^= _BV(PD5); }

int main(void) { // ENable int sei();

/* INITIALIZE 8MHz/256 -> 31 250 Hz */ CLKPR=_BV(CLKPCE); CLKPR=_BV(CLKPS3);

/* enable PD5 as output */ DDRD|= _BV(PD5);

//PCINT1 erlauben PCMSK0=_BV(PCINT1); PCICR=_BV(PCIE0);

//Pull-Up DDRB=0; PORTB=_BV(PORTB1);

/* BLINK, BLINK ... */ while (1) { sleep_mode(); } }

Reply to
P.Marek

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.