Hallo zusammen,
Ich sitze schon seit gestern an diesem Problem rum...
Warum will der Timer nicht inkrementieren?
AVR Studio zeigt in der Simulation TCNT0 konstant 0x00 an...
Und auf meinem STK500 gehts natürlich auch nicht.
hier der komplette code:
Ich hoffe Ihr könnt mir helfen...Code:#include <avr/io.h> #include <avr/interrupt.h> volatile uint8_t timer = 0; // Speichert den aktuellen Zählerwert ISR(TIMER0_OVF_vect) { timer++; } void initTimer(void) { // Initialisierung: TIMSK |= (1<<TOIE0); // Interrupt aktivieren TCCR0A |= (1 << CS00 ) | (1 << CS02); // Timer0 initialisierung, Vorteiler ist 1024 sei(); } void initPorts(void) { DDRB = 0xff; //PortB als Ausgang PORTB = 0xff; // alle LEDs aus } int main() { initPorts(); initTimer(); while (1) { PORTB = ~timer; if(timer==255) timer=0; } return 0; }







Zitieren

Lesezeichen