Witam
Mam problem z timerem w uc Atmega 8. Chciałem sobie napisać zegar,ale nie mogę tego zrobić przy użyciu timera,bo timer w ogóle nie generuje przerwania
licznik chodzi i się przepełnia,bo wyświetliłem sobie jego wartość na lcd żeby sprawdzić co jest nie tak...załączam kod programu,bo już nie mam pomysłów co może być nie tak
Mam problem z timerem w uc Atmega 8. Chciałem sobie napisać zegar,ale nie mogę tego zrobić przy użyciu timera,bo timer w ogóle nie generuje przerwania
$crystal = 8000000
Config Lcdpin = Pin , Db4 = Portd.3 , Db5 = Portd.2 , Db6 = Portd.1 , Db7 = Portd.0 , E = Portd.6 , Rs = Portd.5
Config Lcd = 16 * 2
Config Pinb.1 = Input
Config Pinb.2 = Input
Set Portb.1
Set Portb.2
Cursor Off
Dim Gdz As Byte
Dim Mnt As Byte
Dim Sek As Byte
Config Timer1 = Timer , Prescale = 256
On Timer1 Goto Czas:
Counter1 = 34286 '34286
Enable Interrupts
Enable Timer1
Cls
Home
Do
If Pinb.1 = 0 Then
Waitms 70
If Pinb.1 = 0 Then
Incr Mnt
If Mnt = 60 Then
Mnt = 0
End If
End If
End If
If Pinb.2 = 0 Then
Waitms 70
If Pinb.2 = 0 Then
Incr Gdz
If Gdz = 24 Then Gdz = 0
End If
End If
If Sek = 60 Then
Sek = 0
Incr Mnt
Return
End If
If Mnt = 60 Then
Mnt = 0
Incr Gdz
End If
If Gdz = 24 Then
Gdz = 0
End If
Locate 1 , 1
Lcd "" ; Gdz ; ":" ; Mnt ; ":" ; Sek ; " "
Locate 2 , 1
Waitms 20
Lowerline
Lcd Timer1
Loop
End
Czas:
Counter1 = 34286 '34286
Incr Sek
Return