Witam! Przeczytałem sporo na ten temat i w wypowiedziach kolegów wszystko jest proste - a nie zawsze jest dla początkującego. Napisałem: odbiór RC5 w pętli głównej a drugi programik: odbiór w przerwaniu INT0. Pierwszy działa znakomicie a drugi niestety daje wynik 255. Oto kod 1:
'kody rc5 w pętli głównej
$regfile = "m8def.dat"
$crystal = 8000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.5 , Db5 = Portd.6 , Db6 = Portd.7 , Db7 = Portd.4 , E = Portd.3 , Rs = Portc.0 'konfiguracja linii
Config Rc5 = Pind.2
Enable Interrupts
Dim Adres As Byte , Kod As Byte
Cls
Cursor Off
Locate 1 , 1
Lcd "kod RC5"
Do
Getrc5(adres , Kod)
If Adres < 255 Then
Kod = Kod And &B01111111
Locate 2 , 1
Lcd Kod
End If
Loop
End
ten drugi - nie działający poprawnie:
'kody rc5 w przerwaniu int0
$regfile = "m8def.dat"
$crystal = 8000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.5 , Db5 = Portd.6 , Db6 = Portd.7 , Db7 = Portd.4 , E = Portd.3 , Rs = Portc.0 'konfiguracja linii
Config Rc5 = Pind.2
Enable Interrupts
Dim Adres As Byte , Kod As Byte
Config Int0 = Low Level
Dim Flaga As Bit
Enable Interrupts
Enable Int0
On Int0 Rc5
Cls
Cursor Off
Locate 1 , 1
Lcd "kod RC5"
Do
If Flaga = 1 Then
Locate 2 , 1
Lcd Kod
Enable Int0
Reset Flaga
End If
Loop
End
Rc5:
Disable Int0
Enable Interrupts
Getrc5(adres , Kod)
If Adres = 0 Then
Kod = Kod And &B01111111
End If
Set Flaga
return
W którejś wypowiedzi była sugestia, że może to być wina wersji BASCOMA.
Ja używam 2.0.7.1
Pomóżcie Koledzy w zrozumieniu tematu i rozwiązaniu problemu.
To pierwszy post - za braki wybaczcie...
Kod: basic4gl
'kody rc5 w pętli głównej
$regfile = "m8def.dat"
$crystal = 8000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.5 , Db5 = Portd.6 , Db6 = Portd.7 , Db7 = Portd.4 , E = Portd.3 , Rs = Portc.0 'konfiguracja linii
Config Rc5 = Pind.2
Enable Interrupts
Dim Adres As Byte , Kod As Byte
Cls
Cursor Off
Locate 1 , 1
Lcd "kod RC5"
Do
Getrc5(adres , Kod)
If Adres < 255 Then
Kod = Kod And &B01111111
Locate 2 , 1
Lcd Kod
End If
Loop
End
Kod: basic4gl
ten drugi - nie działający poprawnie:
Kod: basic4gl
'kody rc5 w przerwaniu int0
$regfile = "m8def.dat"
$crystal = 8000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.5 , Db5 = Portd.6 , Db6 = Portd.7 , Db7 = Portd.4 , E = Portd.3 , Rs = Portc.0 'konfiguracja linii
Config Rc5 = Pind.2
Enable Interrupts
Dim Adres As Byte , Kod As Byte
Config Int0 = Low Level
Dim Flaga As Bit
Enable Interrupts
Enable Int0
On Int0 Rc5
Cls
Cursor Off
Locate 1 , 1
Lcd "kod RC5"
Do
If Flaga = 1 Then
Locate 2 , 1
Lcd Kod
Enable Int0
Reset Flaga
End If
Loop
End
Rc5:
Disable Int0
Enable Interrupts
Getrc5(adres , Kod)
If Adres = 0 Then
Kod = Kod And &B01111111
End If
Set Flaga
return
Kod: basic4gl
W którejś wypowiedzi była sugestia, że może to być wina wersji BASCOMA.
Ja używam 2.0.7.1
Pomóżcie Koledzy w zrozumieniu tematu i rozwiązaniu problemu.
To pierwszy post - za braki wybaczcie...