'Testprogramme mit T6963C graphic display 160 x 64 Dot 'Pulsweite von DCF77 Ausgang messen und ausgeben 'µC Atmega32 / Takt 1Mhz / Flash 32Kb '----------------------------------------------------------------- 'Pinbelegung 'LCD pin Signal Verbunden Portbelegung ' 1 VDD ( 5V ) über PNP Port.d 0 '2 GND GND '3 VEE ( -12+-1,5% ) über PNP Port.d 1 '4 /WR µC Port.a 0 '5 /RD µC Port.a 1 '6 /CE µC Port.a 2 '7 /C/D µC Port.a 3 '8 /Halt über pull up '9 /Reset µC Port.a 4 '10 /NC '11-18 D0-D7 µC Port.c 0-7 '19 NC '20 NC 'Taster 1 Portd.2 'Taster 2 Portd.3 'Taster 4 geht an Reset Pin (9) 'Pulsweite DCF77 Portd.6 $regfile = "m32def.dat" $crystal = 1000000 Ddrd = &B00000011 'Bit 0 und 1 als Ausgang Portd = &B11111111 'Bit 0 und 1 High schalten da PNP Transistor 'Bitwait Pind.2 , Reset 'Starttaster 1 abfragen Reset Portd.0 'VDD 5V einschalten Wait 1 Reset Portd.1 'VEE -12V einschalten Wait 1 'First we define that we use a graphic LCD ' Only 240*64 supported yet / in der nächsten Zeile wurde 240 x 128 ausgewählt, da es 160 * 64 nicht gibt Config Graphlcd = 240 * 128 , Dataport = Portc , Controlport = Porta , Ce = 2 , Cd = 3 , Wr = 0 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 8 'The dataport is the portname that is connected to the data lines of the LCD 'The controlport is the portname which pins are used to control the lcd 'CE, CD etc. are the pin number of the CONTROLPORT. ' For example CE =2 because it is connected to PORTC.2 'mode 8 gives 240 / 8 = 30 columns , mode=6 gives 240 / 6 = 40 columns 'Mode = 8 Ergibt 128 / 8 = 16 Spalten Declare Function Lopulse() As Word Dim Value As Word Config Timer0 = Timer , Prescale = 1024 'Eine Zeitscheibe = 1024/1000000Mhz = 0,001024 s On Timer0 Overflow_isr Nosave Enable Timer0 'Timer0 freischalten Enable Interrupts 'Interrupts freischalten Cls 'Display Löschen Cursor Off 'Cursor Aus Waitms 500 '******************************************************************************* '* Pulsweite messen * '******************************************************************************* 'Do ' Cls ' Select Case Value ' Value = Lopulse() ' Case 0 To 77 ' Locate 1 , 1 : Lcd "Fehler Low Wert = " ; Value ' Case 233 To 255 ' Locate 2 , 1 : Lcd "Fehler High Wert = " ; Value ' Case 78 To 132 ' Locate 3 , 1 : Lcd "Pulsweite Bit0 Wert = " ; Value ' Case 168 To 232 ' Locate 4 , 1 : Lcd "Pulsweite Bit1 Wert = " ; Value ' End Select 'Loop Do 'Hauptfunktion,Werte von Fuktion Lopulse an Value übergeben und auf LCD schreiben Cls Value = Lopulse() Locate 1 , 1 : Lcd "Pulsweite = " ; Value Loop End Function Lopulse() As Word 'Funktion Pulsweite messen While Pind.6 <> 1 : Wend 'Wenn Pegel an Pind.6 Low Tcnt0 = 0 'dann Timerwert auf 0 setzen Start Timer0 'Timer0 starten While Pind.6 = 1 : Wend 'wenn Pegel pind.6 High Stop Timer0 'dann Timer0 stoppen Lopulse = Tcnt0 'Timerwerte an Variable Lopulse übergeben End Function Lopulse() Overflow_isr: !push R24 Stop Timer0 Tcnt0 = 0 !pop R24 Return