Gast
#281214
Hilfe! Ich versuche ein ganz einfaches Beispiel zur Nutzung von Countern zu machen. Das Programm soll den Zählerstand auf LED's am Port B ausgeben, aber er bleibt konstant beim Initialisierungswert! #include <avr/io.h> #include <avr/interrupt.h> #include <inttypes.h> #include <stdio.h> // Counter Wert unsigned int Counter = 0xAA; // Timer 0 overflow ISR ISR(SIG_OUTPUT_COMPARE0) { Counter++; } void main(void) { // Port B PORTB=0x00; DDRB=0xFF; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: 7,813 kHz // Mode: Output Compare // OC0 output: Disconnected TCCR0=0x05; TCNT0=0x00; OCR0=0xFF; // External Interrupt(s) initialization // INT0: Off // INT1: Off GIMSK=0x00; MCUCR=0x00; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x03; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; // Global enable interrupts sei(); while (1) { PORTB=Counter; }; }