Forum: Mikrocontroller und Digitale Elektronik [ATMega8;Bascom] 3x PWM Signale


von Herbert G. (feuerfuchs)


Lesenswert?

Hallo,

ich habe bisher in Bascom problemlos mit 2 PWM Signalen und einem 
ATMega8 gearbeitet.

Nun möchte ich eine RGB Led steuern und brauche somit 3 PWM Signale.

Ich habe dazu folgenden Code, bei dem nur eine Farbe leuchten sollte:
1
$regfile = "m8def.dat"
2
$crystal = 4000000
3
4
Dim A As Byte
5
6
7
Config Portb.1 = Output 'Blau, Comp.1a
8
Config Portb.2 = Output 'Rot, Comp1.b
9
Config Portb.3 = Output 'Grün?, Ocr2
10
11
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up , Prescale = 1
12
Config Timer2 = Pwm , Pwm = On , Compare Pwm = Clear Up , Prescale = 1
13
14
15
Do
16
Compare1a = 0
17
Compare1b = 0 '
18
Ocr2 = 255
19
20
Loop
21
22
End

Jedoch leuchtet die LED weiß, d.h. Portb.1, Portb.2 und Portb.3 sind 
alle aktiv, obwohl ich nur einen Port auf 255 gesetzt habe, den Rest auf 
0.
Weiß jemand woran das ligt?

Wenn ich Compare1a oder 1b auf 255 stelle und den Rest auf 0, leuchtet 
die LED wie erwartet.

Danke für eure Hilfe!

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.