PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : [ERLEDIGT] Testprogramm für 2-pin Grafikdisplay Hyundai HP12542R-DYO



PICture
28.05.2006, 17:52
Hallo!

Hier ist geprüfte Hardware und Software für den Hyundai HP12542R-DYO vom Pollin. Es ist mir gelungen die zur Steuerung des Displays nötige Pinanzahl bis auf zwei zu reduzieren.

Vom IC 74HC74 müssen noch Pin7 mit GND und Pin 14 mit VCC verbunden werden.

Der erste Code ist auf den PIC12FXXX und 16FXXX, der zweite auf den 18FXXX lauffähig.

Ich habe das ganze auf einem PIC18F252 mit 10MHz Quarz in PLL (also 40MHz) und auf einem PIC12F629 mit 20MHz Quarz ausprobiert.

Die Initialiesierung habe ich inzwischen geändert und das unerwünschte Effekt mit dem schlechten Kontrast kommt nicht mehr vor. Für niedrigere Quarz (Taktfrequenzen) kann die DEL Verzögerung ensprechend gekürzt werden.

Wenn Probleme geben sollte, bitte fragen!

MfG



.-----------------------------------------------. VCC
| Grafik Display 64x128 pixel | +
| | |
| HP12542R-DYO | .-.
| 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2| | |10k
|1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4| | |
'-----------------------------------------------' '-'
| | | | | | | | | | | | | | | | | |
| === ===| | | | | | | | | |=== |=== \------+
| GND GND| | | | | | | | | |GND |GND |
+---------+-+ | | | | | | | | | | --- µ1
| | | | | | | | | | | ---
| +---+ | | | | | | | | | |
| | +---+ | | | | | | | | ===
VCC | | | +---+ | | | | | | |VCC GND
+ | | | | +---+ | | | | | | +
| | | | | | | | | | | | |
+--+---------+ +-----------------|---------+
| | | | | | | | | | | | | | 74HC74 |
.----------o--.| | | | | | +---+ |
|1 1 1 1 1 9 8|| | | | | | | 4| |
|4 3 2 1 0 || | | | | | |5.-o-.2 |
|) || | | | +---------| |---+------<CK
| 74HC164 || | | | | | | |-+ |
|1 2 3 4 5 6 7|| | | | | | '-o-'3| |
'-------------'| | | | | | 1| | |
| | | | | | | | | | | | +---+ +--------<DT
+-+ | | | |===| | | | | | 10| 12| |
| | | | |GND| | | | | |9.-o-. | |
| | | | +---+ | | | +---| |-+ |
| | | +-------+ | | | | | |---+
| | +-----------+ | | | '-o-'11
| +---------------+ | | 13|
+-------------------------+ +---+

; Testprogramm für Grafikdisplay Hyundai HP12542R-DYO mit 2-pin Anschluss
LIST P=12F629
include "P12F629.inc"
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _HS_OSC
#define _DT GPIO,0 ; nur für PIC12FXXX
#define _CK GPIO,1 ; Displayanschlüsse festlegen
;#define _DT PORTB,7 ; nur für PIC16FXXX
;#define _CK PORTB,6 ; Displayanschlüsse festlegen
#define _C STATUS,C
#define _Finv Flags,0 ; Displayinversion Flag: 0-normal, 1-invers
DTmp EQU 0x20
DTmp1 EQU 0x21
DTmp2 EQU 0x22
DTmp3 EQU 0x23
DTmp4 EQU 0x24
DTmp5 EQU 0x25
Flags EQU 0x26
ORG 0x0000
call Init
Main 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 DTmp5
movlw 0 ; eretes Byte festlegen
movwf DTmp4
MainL1 movf DTmp4,0
call DByte ; das Byte an Display schicken
incf DTmp4,1 ; das Byte incrementieren
decfsz DTmp5,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 DTmp5
MainL2 movf DTmp4,0
call DByte
incf DTmp4,1
decfsz DTmp5,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 DTmp5
movlw 0xFF ; erstes Byte festlegen
movwf DTmp4
MainL3 movf DTmp4,0
call DByte
decf DTmp4,1 ; das Byte decrementieren
decfsz DTmp5,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 DTmp5
MainL4 movf DTmp4,0
call DByte
decf DTmp4,1
decfsz DTmp5,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 DTmp5
movlw 0
movwf DTmp4
MainL5 movf DTmp4,0
call DByte
incf DTmp4,1
decfsz DTmp5,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 DTmp5
MainL6 movf DTmp4,0
call DByte
incf DTmp4,1
decfsz DTmp5,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 DTmp5
movlw 0xFF
movwf DTmp4
MainL7 movf DTmp4,0
call DByte
decf DTmp4,1
decfsz DTmp5,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 DTmp5
MainL8 movf DTmp4,0
call DByte
decf DTmp4,1
decfsz DTmp5,1
goto MainL8
bcf _Finv ; normal
goto Main ; und noch mal vom Anfang (endlos)

Cmd bcf _C ; Schicke ein Befehl zum Display
goto Send
DByte bsf _C ; Schicke ein Databyte zum Display
Send movwf DTmp2
btfsc _Finv ; prüfen, ob invertiert
comf DTmp2,1 ; wenn ja, alle Bits negieren
movlw 9
movwf DTmp3
Ser bcf _CK ; Schicke seriell bitweise ein Byte+A0=C (9 Bit) in den Schieberegister+Flip-Flop
bcf _DT
btfsc DTmp2,7
bsf _DT
bsf _CK
rlf DTmp2,1
decfsz DTmp3,1
goto Ser

bcf _DT ; setze
bsf _DT ; und
bcf _CK ; lösche
bcf _DT ; Display
bsf _DT ; Enable
return

Del movlw 0x20
movwf DTmp
Del1 clrf DTmp1
Del2 clrf DTmp2
Del3 decfsz DTmp2,1
goto Del3
decfsz DTmp1,1
goto Del2
decfsz DTmp,1
goto Del1
return

Init movlw 7 ; Komparator abschalten
movwf CMCON ; und GPIO0-3 als digitale I/O festlegen
bsf STATUS,RP0
clrf TRISIO ; nur für PIC12FXXX
; clrf TRISB ; nur für PIC16FXXX
bcf STATUS,RP0
clrf GPIO ; nur für PIC12FXXX
; clrf PORTB ; nur für PIC16FXXX
clrf Flags
bcf _CK ; lösche
bcf _DT ; Display
bsf _DT ; Enable
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
return
END

; Testprogramm für Grafikdisplay Hyundai HP12542R-DYO mit 2-pin Anschluss
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,WR T0=OFF,WRT1=OFF,WRT2=OFF,WRT3=OFF
CONFIG WRTB=OFF,WRTC=OFF,WRTD=OFF,EBTR0=OFF,EBTR1=OFF,EBT R2=OFF,EBTR3=OFF,EBTRB=OFF
#define _DT PORTB,7 ; Displayanschlüsse
#define _CK PORTB,6 ; festlegen
#define _C STATUS,C
#define _Finv Flags,0 ; Displayinvers Flag: 0-normal, 1-invers
DTmp EQU 0x20
DTmp1 EQU 0x21
DTmp2 EQU 0x22
DTmp3 EQU 0x23
DTmp4 EQU 0x24
DTmp5 EQU 0x25
Flags EQU 0x26
ORG 0x0000
call Init
Main 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 DTmp5
movlw 0 ; eretes Byte festlegen
movwf DTmp4
MainL1 movf DTmp4,0
call DByte ; das Byte an Display schicken
incf DTmp4,1 ; das Byte incrementieren
decfsz DTmp5,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 DTmp5
MainL2 movf DTmp4,0
call DByte
incf DTmp4,1
decfsz DTmp5,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 DTmp5
movlw 0xFF ; erstes Byte festlegen
movwf DTmp4
MainL3 movf DTmp4,0
call DByte
decf DTmp4,1 ; das Byte decrementieren
decfsz DTmp5,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 DTmp5
MainL4 movf DTmp4,0
call DByte
decf DTmp4,1
decfsz DTmp5,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 DTmp5
movlw 0
movwf DTmp4
MainL5 movf DTmp4,0
call DByte
incf DTmp4,1
decfsz DTmp5,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 DTmp5
MainL6 movf DTmp4,0
call DByte
incf DTmp4,1
decfsz DTmp5,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 DTmp5
movlw 0xFF
movwf DTmp4
MainL7 movf DTmp4,0
call DByte
decf DTmp4,1
decfsz DTmp5,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 DTmp5
MainL8 movf DTmp4,0
call DByte
decf DTmp4,1
decfsz DTmp5,1
goto MainL8
bcf _Finv ; normal
goto Main ; und noch mal vom Anfang (endlos)

Cmd bcf _C ; Schicke ein Befehl zum Display
goto Send
DByte bsf _C ; Schicke ein Databyte zum Display
Send movwf DTmp2
btfsc _Finv ; prüfen, ob invertiert
comf DTmp2,1 ; wenn ja, alle Bits negieren
movlw 9
movwf DTmp3
Ser bcf _CK ; Schicke seriell bitweise ein Byte+A0=C (9 Bit) in den Schieberegister+Flip-Flop
bcf _DT
btfsc DTmp2,7
bsf _DT
bsf _CK
rlcf DTmp2,1
decfsz DTmp3,1
goto Ser

bcf _DT ; setze
bsf _DT ; und
bcf _CK ; lösche
bcf _DT ; Display
bsf _DT ; Enable
return

Del movlw 0x40
movwf DTmp
Del1 clrf DTmp1
Del2 clrf DTmp2
Del3 decfsz DTmp2,1
goto Del3
decfsz DTmp1,1
goto Del2
decfsz DTmp,1
goto Del1
return

Init clrf TRISB
clrf PORTB
clrf Flags
bcf _CK ; lösche
bcf _DT ; Display
bsf _DT ; Enable
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
return
END

*Mario*
12.06.2006, 11:11
Hallo PICTure,

super! Tolle arbeit,genau was ich brauche. Ich hab auch so ein Display bei mir herumliegen. Wollte es schon immer mal per PIC in Betrieb nehmen, habe aber vorerst ein S65 Handy Display in Betrieb (Stromverbrauch, Spannung für mobilen Einsatz an einer Knopfzelle).

Danke für das gute Stück Arbeit!

Mario

PICture
13.06.2006, 06:30
Hallo *Mario*!

Nichts zu danken. Ich habe das Programm für mich geschrieben, weil ich mir 4 St. von dem Display für eventuelle zukünftige Anwendungen gekauft habe, und das Display testen wollte. Warum soll ich das nicht für andere, die vielleicht es brauchen, zur Verfugung stellen ?

Übrigens, habe ich ein kleines Nachteil festgestellt, aber bis jetzt weiss ich die Ursache noch nicht sicher. Das Display nach dem Auschalten und sofortigem Einschalten zeigt das Testmuster nicht richtig. Es sieht so aus, dass das Kontrast irgendwie nicht stimmt (ist sehr dunkel). Wenn man aber ca. 1 Minute abwartet und erst dann einschaltet, ist alles wieder in Ordnung. Ich vermute, dass irgendeine innere Spannung bleibt noch für diese Zeit erhalten und stört. Ich weiss auch nicht, ob alle Displays sich so verhalten, da ich bisher nur ein Stück getestet habe. Deswegen freue ich mich sehr für jede Meldung wie es funktioniert.

MfG

*Mario*
15.06.2006, 21:27
Hallo PICture,

so wie das Problem schilderst, klingt das danach, dass Du vor dem Abschalten eine shut-down Sequenz zum LCD schicken musst um den LCD zu entladen. Ich hab aber nicht ins Datenblatt geschaut ob das bei dem Display auch nötig ist bzw. ob das die Ursache sein kann.

Gruß
Mario

PICture
15.06.2006, 21:43
Hallo *Mario*!

Weitere Test haben gezeigt, dass das unerwünschte Effekt mit dem Kontrast auftritt immer wenn die Taktfrequenz höher als 10 MHz ist.

Ich habe inzwischen die Initialisierung des Displays geändert und (hoffentlich) das unerwünschte Effekt mit dem Kontrast beseitigt.

Jetzt wird das Display zuerst abgeschaltet und es wird abgewartet bis die alle interne Spanungen sich entladen. Danach wird das Display wie vorher initialisiert.

Ich habe ausserdem festgestellt, dass der Wert für Kontrast im Bereich 0 bis 3Fh liegen sollte, da aussen diesem Bereich kein Bild mehr sichtbar ist.
Für mich war der Wert 27h optimal, das ist aber warscheinlich vom Exemplar abhängige und individuelle Geschmacksache.

MfG