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

Problem z dokładnością zegarka binarnego

Andrzej_01 11 Sie 2009 12:55 1410 1
REKLAMA
  • #1 6880428
    Andrzej_01
    Poziom 11  
    Witam!
    Wykonałem zegarek binarny z tego linku:
    Link.
    Kondensatory zastosowałem 22pF zamiast 33pF. Mam kwarc 16MHz.
    Kod jaki wgrałem do ATMEGA8 jest tu:
    'TO DZIALA :)
    
    'S1 - godziny
    'S2 - minuty
    
    $regfile = "m8def.DAT"
    $crystal = 16000000
    
    Dim Sekjed As Byte , Sekdzies As Byte , Minjed As Byte , Mindzies As Byte , Maxi As Byte
    Dim , Godzjed As Byte , Godzdzies As Byte , Mux As Byte , Uniwers As Byte
    Config Portd = 255 : Portd = &B255 : Config Portc = &B11111111 : Portc = &B11111111
    Config Portb.2 = Input
            Portb.2 = 1
    Config Portb.3 = Input
            Portb.3 = 1
    Config Timer0 = Timer , Prescale = 64
    Config Timer1 = Timer , Prescale = 256
    Enable Interrupts : Enable Timer0 : Enable Timer1
    On Timer0 Co4ms : On Timer1 Co1s
    Sekjed = 5 : Sekdzies = 5 : Minjed = 1 : Mindzies = 0 : Godzjed = 1 : Godzdzies = 1
    Uniwers = 6
    Maxi = 100
    
    Do
    Loop
    End
    
    Co1s:
    Timer1 = 3036
    Incr Sekjed
    Return
    
    Co4ms:
    Decr Uniwers
    
    If Pinb.3 = 0 And Pinb.2 = 1 Then
       If Uniwers = 0 Then
          Uniwers = Maxi : Incr Minjed : Sekjed = 0 : Sekdzies = 0
          Maxi = Maxi - 8 : If Maxi < 8 Then Maxi = 8
    End If : End If
    If Pinb.2 = 0 And Pinb.3 = 1 Then
       If Uniwers = 0 Then
          Uniwers = Maxi : Incr Godzjed
          Maxi = Maxi - 8 : If Maxi < 12 Then Maxi = 12
    End If : Else
       If Uniwers = 0 Then
          Uniwers = 6 : Maxi = 100
       End If : End If
    If Sekjed = 10 Then
       Sekjed = 0 : Incr Sekdzies
    End If
    If Sekdzies = 6 Then
       Sekdzies = 0 : Incr Minjed
    End If
    If Minjed = 10 Then
       Minjed = 0 : Incr Mindzies
    End If
    If Mindzies = 6 Then
       Mindzies = 0 : Incr Godzjed
    End If
    If Godzjed = 10 Then
       Godzjed = 0 : Incr Godzdzies
    End If
    If Godzdzies = 2 And Godzjed = 4 Then
       Godzdzies = 0 : Godzjed = 0
    End If
    
    Mux = Uniwers And &B111 : Portc = &B111111
    Select Case Mux
    Case 1:
       Portd = Lookup(sekjed , Tabela) : Portc.0 = 0
    Case 2:
       Portd = Lookup(sekdzies , Tabela) : Portc.1 = 0
    Case 3:
       Portd = Lookup(minjed , Tabela) : Portc.2 = 0
    Case 4:
       Portd = Lookup(mindzies , Tabela) : Portc.3 = 0
    Case 5:
       Portd = Lookup(godzjed , Tabela) : Portc.4 = 0
    Case 6:
       Portd = Lookup(godzdzies , Tabela) : Portc.5 = 0
    End Select : Return
    Tabela:
    
     Data 255 , 254 , 253 , 252 , 251 , 250 , 249 , 248 , 247 , 246       'pozytyw
     'Data 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9                           'negatyw


    Nie było mnie w domu 2 tygodnie i po tym czasie zegarek spóźnia 12 minut.

    Proszę o pomoc w znalezieniu błędu. Czy może źle ustawiam fusebity? Załączam zrzut z bascoma.
    Czekam na odpowiedź.
    Pozdrawiam Andrzej.

    Pytania n/t mikrokontrolerów proszę zadawać w dziale Mikrokontrolery. Przeniosłem z Programowanie początkujący.
    [Dr.Vee]
  • REKLAMA
  • #2 6882941
    Konto nie istnieje
    Poziom 1  
REKLAMA