Code:
zu allen paralell eizeln zum gewähl-
geschalteten Displays ten Display
/-----------/\--------\ /------/\-------\
R D D D D D D D D E E E E E E E E
S 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
A A A A A A A A A A A A A A A A A
| | | | | | | | | +-oA | | | | | | | |
| | | | | | | | | S | --o-+ | | | | | | |
| | | | | | | | | | oN . | | | | | | |
| | | | | | | | | | | . | | | | | | |
| | | | | | | | | | +---+ | | | | | | |
VCC | | | | | | | | | | | | | | | | | |
+ | | | | | | | | +--+ | o-o-o-o-o-o-o-o---+
vom PIC 4| | | | | | | | | | | | | | | | | | | | |
2.-o-.5|1,2.-----------------.| | 14.-----------------.===
_DT >-+----|IC1|-+---| 3 4 5 6 1 1 1 1 |+-|---|15 1 2 3 4 5 6 7 |GND
| |/1 | | 0 1 2 3 | | | |
_CK >---+--| o-+---|IC2 74HC164 |+-|---|IC3 74HC595 |
| | 3'-o-'6| 8'--------o--------'| | 11'----o---o---o----'
| | 1| | 9| | | 12| 13| 10|
| | + | + | | | | +
| | VCC | VCC | | | | VCC
| +--------+----------------------+ | | |
| | VCC | | |
| | + IC1=74HC74 | | | | |
| | 10| | | | +-o => o-+
| |12.-o-.9 | | | | | | |
| +--|IC1|--------------------------+--------+ | .-. ===
| |/2 | | | | GND
+----| o---------------------------------------+ | |1k
11'-o-'8 '-'
13| |
+ ===
VCC GND
; Testprogramm für 2-pin Schnittstelle mit mehreren LC Displays
; LIST P=18F252
; include "P18F252.inc"
; CONFIG OSCS=OFF,OSC=HSPLL, PWRT=ON, BOR=OFF, WDT=OFF, CCP2MUX=OFF, STVR=OFF, LVP=OFF, DEBUG=OFF
; CONFIG CP0=OFF,CP1=OFF,CP2=OFF,CP3=OFF,CPB=OFF,CPD=OFF,WRT0=OFF,WRT1=OFF,WRT2=OFF,WRT3=OFF
; CONFIG WRTB=OFF,WRTC=OFF,WRTD=OFF,EBTR0=OFF,EBTR1=OFF,EBTR2=OFF,EBTR3=OFF,EBTRB=OFF
LIST P=16F630
include "P16F630.inc"
__CONFIG _CP_OFF & _BODEN_OFF & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _HS_OSC
#define @PORT PORTC ; Port und
#define @TRIS TRISC ; dazugehörigen TRIS Register festlegen
#define _CK PORTC,2 ; Pins für Displayleitungen
#define _DT PORTC,3 ; definieren
#define _C STATUS,C
#define _Finv Flags,0 ; 0-normal, 1-invers
Tmp EQU 0x20
Tmp1 EQU 0x21
Tmp2 EQU 0x22
Tmp3 EQU 0x23
Tmp4 EQU 0x24
Tmp5 EQU 0x25
Tmp6 EQU 0x26
Flags EQU 0x27
ORG 0x0000
call Init
Main movlw 1 ; Display1
movwf Tmp6 ; auswählen
call GDspOut ; und ausgeben
movlw 2 ; Display2
movwf Tmp6 ; auswählen
call DspOut ; und ausgeben
goto Main ; und noch mal vom Anfang (endlos)
GDspOut movlw 0xB0 ; Page 0 Adresse setzen (1. Zeile)
call Cmd
movlw 0x10 ; Column 0 Adresse setzen (2 Bytes)
call Cmd
movlw 0
call Cmd
movlw 0x80 ; Schleifenzähler festlegen (128d)
movwf Tmp5
movlw 0 ; erstes Byte festlegen
movwf Tmp4
MainL1 movf Tmp4,0
call Char ; das Byte an Display schicken
incf Tmp4,1 ; das Byte incrementieren
decfsz Tmp5,1 ; Schleifenzähler decrementieren
goto MainL1 ; wiederholen bis Schleifenzähler=0
movlw 0xB1 ; Page 1 Adresse setzen (2. Zeile), u.s.w
call Cmd
movlw 0x10
call Cmd
movlw 0
call Cmd
movlw 0x80
movwf Tmp5
MainL2 movf Tmp4,0
call Char
incf Tmp4,1
decfsz Tmp5,1
goto MainL2
movlw 0xB2 ; Page 2 Adresse setzen (3. Zeile), u.s w.
call Cmd
movlw 0x10
call Cmd
movlw 0
call Cmd
movlw 0x80
movwf Tmp5
movlw 0xFF ; erstes Byte festlegen
movwf Tmp4
MainL3 movf Tmp4,0
call Char
decf Tmp4,1 ; das Byte decrementieren
decfsz Tmp5,1
goto MainL3
movlw 0xB3 ; Page 3 Adresse setzen (4. Zeile), u.s.w.
call Cmd
movlw 0x10
call Cmd
movlw 0
call Cmd
movlw 0x80
movwf Tmp5
MainL4 movf Tmp4,0
call Char
decf Tmp4,1
decfsz Tmp5,1
goto MainL4
movlw 0xB4 ; Page 4 Adresse setzen (5. Zeile), u.s.w., wie Page 0
call Cmd
movlw 0x10
call Cmd
movlw 0
call Cmd
bsf _Finv ; invers
movlw 0x80
movwf Tmp5
movlw 0
movwf Tmp4
MainL5 movf Tmp4,0
call Char
incf Tmp4,1
decfsz Tmp5,1
goto MainL5
bcf _Finv ; normal
movlw 0xB5 ; Page 5 Adresse setzen (6. Zeile), u.s.w., wie Page 1
call Cmd
movlw 0x10
call Cmd
movlw 0
call Cmd
bsf _Finv ; invers
movlw 0x80
movwf Tmp5
MainL6 movf Tmp4,0
call Char
incf Tmp4,1
decfsz Tmp5,1
goto MainL6
bcf _Finv ; normal
movlw 0xB6 ; Page 6 Adresse setzen (7. Zeile), u.s.w., wie Page 2
call Cmd
movlw 0x10
call Cmd
movlw 0
call Cmd
bsf _Finv ; invers
movlw 0x80
movwf Tmp5
movlw 0xFF
movwf Tmp4
MainL7 movf Tmp4,0
call Char
decf Tmp4,1
decfsz Tmp5,1
goto MainL7
bcf _Finv ; normal
movlw 0xB7 ; Page 7 Adresse setzen (8. Zeile), u.s.w., wie Page 3
call Cmd
movlw 0x10
call Cmd
movlw 0
call Cmd
bsf _Finv ; invers
movlw 0x80
movwf Tmp5
MainL8 movf Tmp4,0
call Char
decf Tmp4,1
decfsz Tmp5,1
goto MainL8
bcf _Finv ; normal
return
DspOut call FstLine
movlw "T"
call Char
movlw "E"
call Char
movlw "S"
call Char
movlw "T"
call Char
movlw "0"
call Char
movlw "1"
call Char
movlw "2"
call Char
movlw "3"
call Char
movlw "4"
call Char
movlw "5"
call Char
movlw "6"
call Char
movlw "7"
call Char
movlw "8"
call Char
movlw "9"
call Char
movlw "A"
call Char
movlw "B"
call Char
movlw "C"
call Char
movlw "D"
call Char
movlw "E"
call Char
movlw "F"
call Char
call SndLine
movlw "G"
call Char
movlw "H"
call Char
movlw "I"
call Char
movlw "J"
call Char
movlw "K"
call Char
movlw "L"
call Char
movlw "M"
call Char
movlw "N"
call Char
movlw "O"
call Char
movlw "P"
call Char
movlw "Q"
call Char
movlw "R"
call Char
movlw "S"
call Char
movlw "T"
call Char
movlw "U"
call Char
movlw "V"
call Char
movlw "W"
call Char
movlw "X"
call Char
movlw "Y"
call Char
movlw "Z"
call Char
call TrdLine
movlw "t"
call Char
movlw "e"
call Char
movlw "s"
call Char
movlw "t"
call Char
movlw "0"
call Char
movlw "1"
call Char
movlw "2"
call Char
movlw "3"
call Char
movlw "4"
call Char
movlw "5"
call Char
movlw "6"
call Char
movlw "7"
call Char
movlw "8"
call Char
movlw "9"
call Char
movlw "a"
call Char
movlw "b"
call Char
movlw "c"
call Char
movlw "d"
call Char
movlw "e"
call Char
movlw "f"
call Char
call FthLine
movlw "g"
call Char
movlw "h"
call Char
movlw "i"
call Char
movlw "j"
call Char
movlw "k"
call Char
movlw "l"
call Char
movlw "m"
call Char
movlw "n"
call Char
movlw "o"
call Char
movlw "p"
call Char
movlw "q"
call Char
movlw "r"
call Char
movlw "s"
call Char
movlw "t"
call Char
movlw "u"
call Char
movlw "v"
call Char
movlw "w"
call Char
movlw "x"
call Char
movlw "y"
call Char
movlw "z"
call Char
return
FstLine movlw 0x80 ; Adresse der 1. Zeile
goto Cmd
SndLine movlw 0xC0 ; Adresse der 2. Zele
goto Cmd
TrdLine movlw 0x94 ; Adresse der 3. Zeile
goto Cmd
FthLine movlw 0xD4 ; Adresse der 4.Zeile
Cmd movwf Tmp2
call DDel
bcf _C ; Schicke Befehl
goto SendR
Val movwf Tmp1 ; Schicke Zahl (0-FF)
swapf Tmp1,0
movwf Tmp4
call Num
movf Tmp1,0
movwf Tmp4
Num call DDel
movf Tmp4,0
andlw 0x0F ; Schicke Ziffer (0-F)
movwf Tmp2
movlw 0x0A
subwf Tmp2,0
btfsc _C
addlw 7
addlw 0x3A
Char bsf _C ; Schicke ASCII Zeichen
btfsc _Finv ; prüfen, ob invertiert
comf Tmp2,1 ; wenn ja, alle Bits negieren
movwf Tmp2 ; Schicke ein Byte + RS (9 bits)
SendR movlw 8 ; Schicke Registerinhalt
movwf Tmp3
SerSendE bcf _CK ; Schicke seriell (bitweise) Enable (8bit) in 74HC595
bcf _DT
btfsc Tmp6,7
bsf _DT
bsf _CK
; rlcf Tmp6,1 ; nur für PIC18FXXX aktivieren
rlf Tmp6,1 ; nur für PIC16FXXX aktivieren
decfsz Tmp3,1
goto SerSendE
; rlcf Tmp6,1 ; nur für PIC18FXXX aktivieren
rlf Tmp6,1 ; nur für PIC16FXXX aktivieren
movlw 9
movwf Tmp3
SerSend bcf _CK ; Schicke seriell (bitweise) Data+RS (9bit) in 74HC164
bcf _DT
btfsc Tmp2,7
bsf _DT
bsf _CK
; rlcf Tmp2,1 ; nur für PIC18FXXX aktivieren
rlf Tmp2,1 ; nur für PIC16FXXX aktivieren
decfsz Tmp3,1
goto SerSend
call DDel
bcf _DT ; set
bsf _DT ; Display Enable
bcf _DT
call DDel
bcf _CK ; clear
bcf _DT ; Display
bsf _DT ; Enable
bcf _DT
call DDel
return
Del movlw 0x20
movwf Tmp
Del1 clrf Tmp1
Del2 clrf Tmp2
Del3 decfsz Tmp2,1
goto Del3
decfsz Tmp1,1
goto Del2
decfsz Tmp,1
goto Del1
return
DDel movlw 0x40
movwf Tmp3
DDelL decfsz Tmp3,1
goto DDelL
return
Init bsf STATUS,RP0 ; nur für PIC16FXXX aktivieren
clrf @TRIS ; Mache B0-B7 Ausgänge
bcf STATUS,RP0 ; nur für PIC16FXXX aktivieren
clrf @PORT
clrf Flags
bcf _DT ; Lösche Display Enable
movlw 1 ; Grafikdisplay initialisieren
movwf Tmp6
movlw 0xAE ; Display aus
call Cmd
call Del ; abwarten
movlw 0xA3 ; LCD Bias=1/7
call Cmd
movlw 0x2F ; LCD Spannungserzeugung einschalten
call Cmd
movlw 0x81 ; Kontrasteinstellung auswählen
call Cmd
movlw 0x20 ; Kontrast=mittel
call Cmd
movlw 0xAF ; Display ein
call Cmd
movlw 2 ; Matrixdisplay initialisieren
movwf Tmp6
movlw 0x38 ; 8 bit, 2 Zeilen , 5x7 Pixel
call Cmd
movlw 0x0C ; Display ein, Cursor aus, nicht blinken
call Cmd
movlw 6 ; Incrementieren, nicht schieben
call Cmd
return
END
Lesezeichen