Hello all,
first of all: I hope that this is the correct forum, if not, please give
me a hint.
2nd: I searched a couple of days, but did not find anything, so now, I
need someone who likes to help me.
I run an Atmel ATMEGA 644 on a Pollin Net-I/O board and try "from
scratch" to setup a simple timer 0 interrupt.
The code looks like this:
#include <stdint.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
ISR(BADISR_vect)
{
// catch up all interrupts for which no ISR is defined
}
ISR (TIMER0_OVF_vect)
{
PORTC |= (1<< PC1); // LED on
_delay_us(200);
PORTC &= ~(1<< PC1); // LED off
}
// ********************** main function **************************
int main(void) { // main function begins here
DDRC |= (1<<PC0) | (1<<PC1); // set C.0 and C.1 as output
TCCR0B = 1<<CS02;
TIMSK0 |= (1<<TOIE0); // unmask timer0 interrupt
sei(); // enable interrupts
for (;;) {
PORTC |= (1<<PC0); // LED on
_delay_ms(200);
PORTC &= ~(1<<PC0); // LED off
_delay_ms(200);
}
return (0); // return from function main (never reached)
}
|
The strange thing is that the code after sei() is never reached, means
the LED 0 is never blinking. If I comment out the sei() OR the TCCR0B =
line, the LED 0 blinks.
(LED 1 stays dark in both cases)
If I try to use "external clock source on T0 Pin" (CS02 | CS01) the code
"LED 0" is also reached, but obviously the ISR is not executed.
I also tried to configure Timer 1 with the same effect.
IMHO, the problem must be very trivial, but I don't have any clue
anymore.
I really appreciate some ideas / hints from you, TIA!