Gast
#4982761
Hallo, ich bin derzeit dabei die Programmierung von AVR's zu erlernen und bin dementsprechend Anfänger. Ich hab zuletzt mit dem ATtiny85 rumgespielt und dabei ein Verständnisproblem was den Timer/Counter1 betrifft, welcher doch etwas anders ist als Timer0 sowie die Timer der ATmega's mit denen ich zu tun hatte. Aus dem Datenblatt des ATtiny85 (http://www.atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf): - Bit 7 – CTC1 : Clear Timer/Counter on Compare Match When the CTC1 control bit is set (one), Timer/Counter1 is reset to $00 in the CPU clock cycle after a compare match with OCR1C register value. If the control bit is cleared, Timer/Counter1 continues counting and is unaffected by a compare match. - Bit 6 – PWM1A: Pulse Width Modulator B Enable When set (one) this bit enables PWM mode based on comparator OCR1B in Timer/Counter1 and the counter value is reset to $00 in the CPU clock cycle after a compare match with OCR1C register value. Beispiel-Code (PWM Output auf Pin1 des ATtiny's): // Timer 1 TCCR1 = _BV (CS11) |_BV (COM1A1) | _BV (PWM1A); // clear OC1B on compare, Prescaler 2, FastPWM OCR1A = 10; // duty cycle OCR1C = 150; // frequency Was genau passiert, wenn man zusätzlich im TCCR1 Registern das CTC1 Bit setzt, da ja schon nach meinem Verständnis das PWM1A Bit das CTC1 Verhalten beinhaltet? Beziehungsweise für welchen Fall würde man sowohl CTC1, als auch PWM1A setzen? Über jegliche Hilfe, beziehungsweise Hinweise würde ich mich freuen. Gruß Leo