Chcę uzyskać w timerze0 przerwanie co 4 ms mam oscylator 4 Mhz na attiny2313, programuje w bascomie. Robie to tak
Jak widać jest to stoper. Jestem poczatkujacy i nie kumam czemu mi miga wyswietlacz i liczba która ma sie zmienić co 100ms zmienia sie co ~4 sekundy.
Config Portb = &B11111111
Portb = &B11111111
Config Portd = &B1111100
Portd = &B0111111
Config Timer0 = Timer , Prescale = 64
Enable Interrupts
Enable Timer0
On Timer0 Przerwanie
Dim Liczy As Bit
Dim 100ms As Byte
Dim Dziesek As Byte
Dim Sekjed As Byte
Dim Sekdzies As Byte
Dim Minjed As Byte
Dim Ktorywysw As Byte
Do
Loop
End
Przerwanie:
Timer0 = 6
If Pind.0 = 0 Then Liczy = 1
If Pind.1 = 0 Then Liczy = 0
If Liczy = 1 Then
Incr 100ms
If 100ms = 25 Then
100ms = 0
Incr Dziesek
If Dziesek = 10 Then
Dziesek = 0
Incr Sekjed
If Sekjed = 10 Then
Sekjed = 0
Incr Sekdzies
If Sekdzies = 6 Then
Sekdzies = 0
Incr Minjed
If Minjed = 10 Then Minjed = 0
End If
End If
End If
End If
End If
Incr Ktorywysw
If Ktorywysw = 4 Then Ktorywysw = 0
Portd.3 = 1
Portd.4 = 1
Portd.5 = 1
Portd.6 = 1
Select Case Ktorywysw
Case 0:
Portb = Lookup(dziesek , Tabela)
Portd.3 = 0
Case 1:
Portb = Lookup(sekjed , Tabela)
Portd.4 = 0
Case 2:
Portb = Lookup(sekdzies , Tabela)
Portd.5 = 0
Case 3:
Portb = Lookup(minjed , Tabela)
Portd.6 = 0
End Select
Return
Tabela:
Data 192 , 249 , 164 , 176 , 153 , 146 , 130 , 248 , 128 , 144
Jak widać jest to stoper. Jestem poczatkujacy i nie kumam czemu mi miga wyswietlacz i liczba która ma sie zmienić co 100ms zmienia sie co ~4 sekundy.