Guten morgen,
ich versuche auf einem AtMega8 2 PWM zum laufen zu bekommen. Die erste
funktioniert einwandfrei. Bei dem 2. Kanal klappt das irgendwie nicht.
Alle möglichen Varianten und suchen waren bisher Erfolglos. Vielleicht
kann mir jemand den Fehler sagen.
Es soll für den 2. Kanal einfach ein NTC ausgelesen und der Wert in das
Register geschrieben werden. Ich lasse mir den Wert auf nem Display
anzeigen. Das passt auch. Nur wird der Wert nicht vernünftig übergeben.
Wenn allerdings in "luftaus" oder "luftvoll" gesprungen wird passt es...
nur eben die Regelung nicht...
Initialisierung:
pwmset1:
ldi temp1, 0b10000010
out TCCR1A, temp1
ldi temp1, 0b00011001
out TCCR1B, temp1
;
ldi temp1, 0x00
out ICR1H, temp1
ldi temp1, 0xff
out ICR1L, temp1
;
ldi temp1, 0x00
out OCR1AH, temp1
ldi temp1, 0x30
out OCR1AL, temp1
pwmset2:
ldi temp1, 0b01101001
out TCCR2, temp1
;
ldi temp1, 0xfe
out OCR2, temp1
--------------------------------
luft:
sbi PORTC,4
ldi temp1, 0b11100101
out ADMUX, temp1
sbi ADCSRA, ADSC
luft1:
sbis ADCSRA, ADIF
rjmp luft1
in ZH, ADCH
mov temp1, ZH
mov temp2, temp1
subi temp1, 0xa0
brcc luftaus
clz
clc
mov temp1, temp2
subi temp1, 0x46
brcs luftvoll
mov temp2,temp1
add temp1, temp2
add temp1, temp2
com temp1
mov temp2, temp1
rcall lcd_clear
rcall lcd_number
mov temp1, temp2
out OCR2, temp1
clc
ret
luftaus:
ldi temp1, 0x01
out OCR2, temp1
clc
ret
luftvoll:
cbi PORTC,4
ldi temp1, 0xfe
out OCR2, temp1
clc
ret