logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

dekoder RC5 przestał działać po przekompilowaniu 2051>MEG

tom1eczek 07 Sie 2007 17:13 887 0
REKLAMA
  • #1 4155055
    tom1eczek
    Poziom 20  
    Posty: 523
    Pomógł: 30
    Ocena: 21
    Witam, dla mikrokontorlera AT89C2051 napisałem kod dekodujący RC5. Teraz przerzucam sie na atmegę16 i wszystkie programy w ktorych zawarta jest obługa RC5 na bazie tego testa nie działają.
    Oczywiscie o takich rzeczach ja zamiana potów z P1.1 na porta.0 to pamiętam. Układ jest sprawny, na PD.2 dochodzi sygnał z TSOP'a.
    Kod (już po przetłumaczeniu z bascom 8051 na AVR) wygląda tak:
    $regfile = "m16def.dat"
    $crystal = 8000000
    Config Scl = Portc.0
    Config Sda = Portc.1
    Config Rc5 = Portd.2
    Config Lcd = 16 * 1
    Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Porta.3 , Rs = Porta.2
    Cursor Off
    
    Dim Kod As Byte
    Dim Comm As Byte
    Dim Sad As Byte
    Dim Abc As Byte
    
    Config Int0 = Low Level
    On Int0 Receiverc5
    Enable Interrupts
    Enable Int0
    Cls
    Lcd "czekam na RC5"
    Do
    If Kod = 1 Then
    Disable Int0
    Set Portd.6
    Cls
    Lcd "com " ; Comm
    Locate 1 , 11
    Lcd "adr " ; Sad
    Kod = 0
    Enable Int0
    Reset Portd.6
    End If
    Loop
    
    Receiverc5:
    Getrc5(sad , Comm)
    Kod = 1
    Return
    End 


    Z tym że jego działanie konczy sie wyrzuceniu na lcd napisu czekam na rc.

    Na forum znalazłem kilka progrmów obługujących RC5 dla avr'ów (jeden z nich na dole), ale na bazie tego mojego (to ten góny kod) napisałem sporo programów, i musiałbym je dokumentnie przebudować. Dlatego mam pytanie co w nim jest źle.

    Przykład sciagnity z forum
    $regfile = "m16def.dat"
    $crystal = 8000000
    Config Scl = Portc.0
    Config Sda = Portc.1
    Config Rc5 = Portd.2
    Config Lcd = 16 * 1
    Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Porta.3 , Rs = Porta.2
    Cursor Off
    
    Dim sad As Byte
    Dim sad1 As Byte
    Dim comm As Byte
    Dim comm1 As Byte
    
    Config Int0 = Low Level
    On Int0 Pobr_rc5
    Enable Interrupts
    Enable Int0
    sad1 = 255
    comm1 = 255
    Cls
    Lcd "czekam na kod"
    Wait 2
    
    Do
    cls
    Locate 1 , 1
    Lcd "Adr " ; sad1 ; "kom " ; comm1
    
    Enable Int0
    
    Loop
    End
    
    Pobr_rc5:
     Disable Int0
     Enable Interrupts
     Getrc5(sad , comm)
     comm = comm And &B01111111
       If sad < 255 Then
          sad1 = sad
          comm1 = comm
       End If
    Return
    End                                     'end program
  • REKLAMA
REKLAMA