witam. W jaki sposób można wysterować trzema kanałami pwn w atmega 8? Mam kilka koncepcji, ale albo są zbyt skomplikowane programowo, sprzętowo, albo po prostu mają wady...
Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tam$regfile = "m8def.dat"
$crystal = 8000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.4 , Db6 = Portc.5 , Db7 = Portd.0 , E = Portc.2 , Rs = Portc.1
Config Pinb.1 = Output
Config Pinb.2 = Output
Config Pinb.3 = Output
Cursor Off
Cls
Rem konfiguracja portów
Dim R As Byte
Dim G As Byte
Dim B As Byte
Dim Pr As Bit
Dim Pg As Bit
Dim Pb As Bit
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 8
Config Timer2 = Pwm , Async = Off , Pwm = On , Compare Pwm = Clear Up , Prescale = 1
Enable Interrupts
Enable Timer2
Enable Timer1
Pwm1a = 0
Pwm1b = 0
Ocr2 = 0
Do
If R <= 1 Then
Pr = 1
End If
If R >= 180 Then
Pr = 0
End If
If G <= 1 Then
Pg = 1
End If
If G >= 252 Then
Pg = 0
End If
If B <= 1 Then
Pb = 1
End If
If B >= 240 Then
Pb = 0
End If
If Pr = 1 Then
Incr R
End If
If Pr = 0 Then
Decr R
End If
If Pg = 1 Then
Incr G
Incr G
End If
If Pg = 0 Then
Decr G
End If
If Pb = 1 Then
Incr B
End If
If Pb = 0 Then
Decr B
Decr B
End If
Pwm1a = R
Pwm1b = G
Ocr2 = B
Locate 1 , 1
Lcd R ; " " ; G ; " " ; B ; " "
Waitms 250
Loopzmienna = RND( zakres )