Mam taki fragment kodu:
Chce, żeby podprogram Kolor był wykonywany co 1000ms, tylko, ze nie mogę tego skonfigurować, a nie znalazłem żadnego kodu, który by mi przy tym działał. W czym tkwi problem?
Config Portb = Output
Portb.0 = 1
Config Portd = Output
Config Portc = Output
Config Porta = Input
Declare Sub Kolor 'podprogram - nazwa
Enable Interrupts ' zezwolenie na obsługę przerwań
Config Timer0 = Timer , Prescale = 1024
Enable Timer0
On Timer0 Kolor
Timer0 = 1
Do
'program
Loop
Kolor: 'poczatek podprogramu
If Portb.0 = 1 And Portb.1 = 0 And Portb.2 = 0 Then 'czerwony
Portb.0 = 0
Portb.1 = 1
Portb.2 = 0
Return
End If
If Portb.0 = 0 And Portb.1 = 1 And Portb.2 = 0 Then 'zielony
Portb.0 = 0
Portb.1 = 0
Portb.2 = 1
Return
End If
If Portb.0 = 0 And Portb.1 = 0 And Portb.2 = 1 Then 'niebieski
Portb.0 = 1
Portb.1 = 1
Portb.2 = 0
Return
End If
If Portb.0 = 1 And Portb.1 = 1 And Portb.2 = 0 Then 'czerwony+zielony
Portb.0 = 0
Portb.1 = 1
Portb.2 = 1
Return
End If
If Portb.0 = 0 And Portb.1 = 1 And Portb.2 = 1 Then 'zielony+niebieski
Portb.0 = 1
Portb.1 = 0
Portb.2 = 1
Return
End If
If Portb.0 = 1 And Portb.1 = 0 And Portb.2 = 1 Then 'czerwony+niebieski
Portb.0 = 1
Portb.1 = 1
Portb.2 = 1
Return
End If
If Portb.0 = 1 And Portb.1 = 1 And Portb.2 = 1 Then 'czerwony+zielony+niebieski
Portb.0 = 1
Portb.1 = 0
Portb.2 = 0
Return
End IfChce, żeby podprogram Kolor był wykonywany co 1000ms, tylko, ze nie mogę tego skonfigurować, a nie znalazłem żadnego kodu, który by mi przy tym działał. W czym tkwi problem?