Du könntest dein Programm z.B. so abändern:
Deine Angaben von $crystal=4.000.000, Prescaler=64 und Timer Startwert = 7936 passen nicht zusammen. Die ISR soll doch bestimmt einmal pro Sekunde aufgerufen werden. Deine Werte passen aber zu einem Quarz mit der Frequenz 3686400Hz.Code:$regfile = "m8def.dat" 'für Mega8 $crystal = 4000000 ' /// UHR Dim Sekunde As Word Dim Minute As Word Dim Stunde As Word Dim H As String * 2 Dim H1 As String * 2 Dim M As String * 2 Dim M1 As String * 2 Dim S As String * 2 Dim S1 As String * 2 Ddrc.0 = 0 'PortC.0-3 als Eingang Ddrc.1 = 0 Ddrc.2 = 0 Ddrc.3 = 0 Portc.0 = 1 'PullUps ein, Taster schaltet Pin nach GND Portc.1 = 1 Portc.2 = 1 Portc.3 = 1 '// Zum setzten von Stunde Minute Sekunde setzen Sekunde = 00 Minute = 00 Stunde = 00 '/// LCD /// Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , _ Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2 Config Lcd = 16 * 2 Cls cursor off '/// TIMER //// Config Timer1 = Timer , Prescale = 64 Const Startwert = 7936 On Timer1 Ontimer1 'Interrupt-Routine für Timer1-Overflow Enable Timer1 'Timer1-Overflow-Interrupt einschalten Enable Interrupts 'Interrupts global zulassen '------------------------------------------------------------------------------- Main: Do 'Uhrzeit in Sekunde Minute Stunde If Sekunde > 59 Then Sekunde = 0 Incr Minute End If If Minute > 59 Then Minute = 0 Incr Stunde End If If Stunde > 23 Then Stunde = 0 End If '/// LCD Anzeige Stunde Minute Sekunde Home H = Str(stunde) H1 = Format(h , "00") M = Str(minute) M1 = Format(m , "00") S = Str(sekunde) S1 = Format(s , "00") Lcd H1 ; ":" ; M1 ; ":" ; S1 Waitms 100 Loop End '////////////////// Ontimer1: Timer1 = Startwert If Pinc.0 = 1 Then Incr Minute : If Minute = 60 Then Minute = 0 If Pinc.1 = 1 Then Decr Minute : If Minute = 255 Then Minute = 59 If Pinc.2 = 1 Then Incr Stunde : If Stunde = 60 Then Stunde = 0 If Pinc.3 = 1 Then Decr Stunde : If Stunde = 255 Then Stunde = 59 Incr Sekunde Return
Config LCD = 16*2 hast du zweimal drin, Config LCDBUS=4 musst du weglassen, wenn du die Pins einzeln angibst.






Zitieren

Lesezeichen