'quick demo of LCD modual By Edward Rupp ' LCD & 8 key I/O board 8-30-03 ver 1.0 ' Use internial RC for clock, limits ser to 2400 ' ICSP ablity with LCD & key board serial via same plug ' Pin 1 ground ' Pin 2 HV ser program init ' Pin 3 ICSP pgrm clock or TX to host for LCD key serial from pin B6 ' Pin 4 ICSP prgm DATA or RX from host for LCD key serial to pin B7 ' No Pizo speaker on board version, no sound support ' For 16F628 'Pin # Pin Name Connection '1 A2 LCD pin 13 Data bit 6 '2 A3 LCD pin 14 Data bit 7 '3 A4 LCD pin 4 Registor Select '4 A5 High Voltage Program ICSP pin 2 '5 Ground '6 B0 74LS165 pin 1 SH/LD Shift Load '7 B1 Unused but with pad posably for hardware RX serial I/O '8 B2 Unused but with pad posably for hardware TX serial I/O '9 B3 LCD pin 6 Enable '10 B4 74LS165 pin 15 Clock Inhibit '11 B5 74LS165 pin 2 Clock '12 B6 ICSP & TTL serial header pin 3 Program Clock or TX com '13 B7 ICSP & TTL serial header pin 4 Program Data or RX com '14 +5 volts '15 A6 74LS165 pin 9 QH '16 A7 Unused but with pad posably for external clock for higher speed '17 A0 LCD pin 11 Data bit 4 '18 A1 LCD pin 12 Data bit 5 INCLUDE "modedefs.bas" @ device INTRC_OSC_NOCLKOUT 'use internal RC clock DEFINE OSC 4 'DEFINE CHAR_PACING 50 'DEFINE HSER_RCSTA 90h for hardware serial 'DEFINE HSER_TXSTA 20h 'DEFINE HSER_BAUD 2400 'DEFINE HSER_SPBRG 25 CMCON = 7 'For 16F628, unrem to turnoff compariters Low PORTB.6 KeyBoard VAR BYTE Debounce VAR BYTE Debounce = 1 OldKey VAR BYTE Data1 VAR BYTE Pause 200 LCDOut $FE,1 Pause 500 LCDOut $FE,2,"LCD ready" Pause 500 LCDOut $FE,1 Loop: 'Test display board by sending key values to display LCDOut $FE,2,"Test Board ",#KeyBoard LCDOut $FE,$C0,"Ser Data In ",#Data1 SerIn PORTB.7,N2400,155,NoData,Data1 'Receave data Pause 5 'if no data showed jump to nodata, if did receave, wait short time and trasmitt NoData: 'jump to here if there was no data from main SerOut PORTB.6,N2400,[KeyBoard] 'Send keyboard data Key: ' 8 key button set with 74LS165 parallel to serial chip PulsOut PORTB.0,1 ' Bring shift / load down momentarily Low PORTB.4 ' Bring CLK inhibit low ShiftIn PORTA.6,PORTB.5,0,[KeyBoard] 'clock data in High PORTB.4 ' Bring CLK inhibit high 'debounce filter IF KeyBoard <> OldKey Then 'if the new and old key values are difrent reset the debounce timer Debounce = 1 EndIF IF KeyBoard = OldKey Then 'if new and old key values are same start debounce timer Debounce = Debounce + 1 IF Debounce > 15 Then 'but reset debounce after 15 loops, maybe holding down key Debounce = 1 EndIF EndIF IF Debounce > 1 Then Loop 'if key is held down long one pass is alowed to pass every 30000 loops OldKey = KeyBoard 'store Keyboard value in oldkey to use for debounce comparisons GoTo loop