Oui, des trucs bizarres mais c'est trop rapide pour voir quoi. Sinon le reste du temps c'est des carrés noirs. En réglant le contraste y a pas d'améliorations.
En fait ce léger mieux c'est depuis que tu m'as fait faire les modif.
-----
Oui, des trucs bizarres mais c'est trop rapide pour voir quoi. Sinon le reste du temps c'est des carrés noirs. En réglant le contraste y a pas d'améliorations.
En fait ce léger mieux c'est depuis que tu m'as fait faire les modif.
OK, je vais te donner la modif à ajouter pour envoyer le quartet de l'init...
J'ai ouvert ton lien du datasheet, et c'est un KS0066U qui gère le LCD.
Donc, le post#22 est exactement la procédure à suivre.
David.
J'ai trouvé ça dans le datasheet du controleur :
6) Function Set
RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0 0 0 0 1 DL N F - -
DL: Interface data length control bit
When DL = “High”, it means 8-bit bus mode with MPU.
When DL = “Low”, it means 4-bit bus mode with MPU. Hence, DL is a signal to select 8-bit or 4-bit bus mode.
When 4-bit bus mode, it needs to transfer 4-bit data twice.
N: Display line number control bit
When N = “Low”, 1-line display mode is set.
When N = “High”, 2-line display mode is set.
F: Display font type control bit
When F = “Low”, 5 ´8 dots format display mode is set.
When F = “High”, 5 ´11 dots format display mode.
Est ce que pour la ligne ";set 4 bit, 2 lines, 5x7 font", il ne faudrait pas plutôt mettre :
movlw b'00001110'
plutôt que : movlw b'00100010'
Merci
Non, c'est avec l'utilisation de l'interface 8bits.
Ouvre le datasheet d'un KSU0066U pour voir la procédure exacte d'initialisation en mode 4bits
Un lien du datasheet :
http://www.asix-tools.com/download/pvk40/ks0066u.pdf
David.
Oups j'ai fait une trompaison !!!
Je voulais dire : movlw b'00001010' au lieu de b'00100010'
PS : je me base déjà sur ce datasheet.
Voici la modif :
Code:movlw b'00100010' ;set 4 bit, 2 lines, 5x7 font call lcdcommand movlw b'11000000' ;2 lignes on bcf shadowb,lcdrs ;set instruction mode in flags register movwf wlcdtemp ;save w! movlw d'1' call _200usecs ;wait min. .2 ms (we don't read busy flag) bcf shadowb,lcde ;set e strobe low (default) movf wlcdtemp,w ;recover original andlw b'11110000' ;just high bits first movwf nibbles ;save high nibbles movf shadowb,w ;get control bits from flags andlw b'00001111' ; they are in lower 4 bits iorwf nibbles,w ;save result in w movwf portb ;output high bits and controls... bsf portb,lcde ;begin enable strobe... nop ;add extra 1 us delay bcf portb,lcde ;end enable strobe bsf shadowb,lcdrs ;default in flags is data mode bcf shadowb,lcde ;default in flags is strobe enable low movf wlcdtemp,w ;we have w back! movlw d'4' call wmillisecs ;wait another 4 ms (we don't read busy flag) movf wlcdtemp,w ;we have w back! movlw b'00001100' ;display on, cursor off,blink off call lcdcommand call lcdclear ;clear lcd movlw b'00000110' ;increment cursor and no display shift call lcdcommand Boucle goto Boucle
Tu remplaces par ce bout de code et tu tests avec la boucle sans fin...
Avec la boucle sans fin, ton LCD ne doit plus avoir de "carrés" noir, l'écran doit sembler comme non alimenté.
David.
Ok, mais c'est quoi la boucle sans fin ?
Pour l'initialisation, si tu as le document Samsung, c'est la page 27 du datasheet.
"Boucle sans fin" te permet de tester si l'init est correcte.
David.
J'ai mis tout ce que tu m'as donné en remplaçant sous :
";from here on out we use 4 bit interface!
;proper delays are built-in."
Mais j'arrive pas à faire le build :
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 929 : Argument out of range (0401 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 1127 : Argument out of range (0401 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 1429 : Argument out of range (0401 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 1537 : Argument out of range (0400 not between 0000 and 03FF)
Message[302] C:\MPLAB PROJET\CMETER\CMETERA.ASM 1552 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\MPLAB PROJET\CMETER\CMETERA.ASM 1601 : Register in operand not in bank 0. Ensure that bank bits are correct.
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 1690 : Argument out of range (0401 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 1931 : Argument out of range (0402 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 1957 : Argument out of range (0402 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 1970 : Argument out of range (0402 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 1999 : Argument out of range (0402 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2066 : Argument out of range (0402 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2128 : Argument out of range (0401 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2130 : Argument out of range (0401 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2132 : Argument out of range (0401 not between 0000 and 03FF)
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2134 : Argument out of range (0401 not between 0000 and 03FF)
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2134 : Address exceeds maximum range for this processor.
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2141 : Address exceeds maximum range for this processor.
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2152 : Address exceeds maximum range for this processor.
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2154 : Address exceeds maximum range for this processor.
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2158 : Address exceeds maximum range for this processor.
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2159 : Argument out of range (0407 not between 0000 and 03FF)
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2159 : Address exceeds maximum range for this processor.
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2161 : Address exceeds maximum range for this processor.
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2164 : Address exceeds maximum range for this processor.
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2168 : Address exceeds maximum range for this processor.
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2169 : Argument out of range (0408 not between 0000 and 03FF)
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2169 : Address exceeds maximum range for this processor.
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2171 : Address exceeds maximum range for this processor.
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2172 : Address exceeds maximum range for this processor.
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2175 : Address exceeds maximum range for this processor.
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2176 : Argument out of range (040C not between 0000 and 03FF)
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2176 : Address exceeds maximum range for this processor.
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2178 : Argument out of range (0404 not between 0000 and 03FF)
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2178 : Address exceeds maximum range for this processor.
Halting build on first failure as requested.
BUILD FAILED: Sat Sep 22 15:02:01 2007
Problèmes...
Avec l'ajout des lignes, on dépasse la mémoire du pic...
Je ne vois pas comment on va pouvoir se débrouiller avec un manque de mémoire!
David.
Essaye ça pour voir si il y a un dépassement mémoire :
David.Code:movlw b'00100010' ;set 4 bit, 2 lines, 5x7 font call lcdcommand movlw b'11000000' ;2 lignes on bcf shadowb,lcdrs ;set instruction mode in flags register movwf portb ;output high bits and controls... bsf portb,lcde ;begin enable strobe... nop ;add extra 1 us delay bcf portb,lcde ;end enable strobe movlw d'4' call wmillisecs ;wait another 4 ms (we don't read busy flag) movlw b'00001100' ;display on, cursor off,blink off call lcdcommand call lcdclear ;clear lcd movlw b'00000110' ;increment cursor and no display shift call lcdcommand Boucle goto Boucle
C'est bon, j'essaye tout de suite !
Excuses moi finalement c'est pas bon :
Error[126] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2160 : Argument out of range (0400 not between 0000 and 03FF)
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2160 : Address exceeds maximum range for this processor.
Warning[220] C:\MPLAB PROJET\CMETER\CMETERA.ASM 2162 : Address exceeds maximum range for this processor.
Halting build on first failure as requested.
BUILD FAILED: Sat Sep 22 15:25:58 2007
ton LCD doit-être dur d'oreille voit ici
Certains LCD à l'init il sont un peu dur d'oreille,il faut leur envoyer 3 ou 4 fois l'info du passage en 8bits (3h)
modifie le programme et fait cette repetiton
a bientôt
C'est pas à ce niveau ?
lcdreset
movlw d'16'
call initwlcd ;wait 16 ms (may be power up condition)
;do lcd song and dance init thing
movlw d'1'
call initwlcd ;wait 1 ms (may be power up condition)
;do lcd song and dance init thing
;most data sheets show 3 initializations,
;but I have always found 2 to be enough.
Vire deux lignes en commentaire dans la routine suivante pour le test :
bin2dec
David.
Mais la tu fais une int en 4 bits moi je te parle au tout début à la mise en service il faut envoyer un salve pour être sur qui a compris qui doit être en 8bits,puis passer en 4 bits,nb de ligne , taille caracteres
puis affichage .Allez salut je part en touche
courage!
a bientôt
J'ai essayé d'enlever des lignes de commentaires, cad entre ;.
Ca marche pas.
Je sais pas si j'ai bien compris mais en fait le numéro de la ligne où l'erreur est signalée change mais il y a toujours la même erreur.
Je pensais que les commentaires n'influaient pas sur la taille du programme lui-même.
Petite précision : si j'enlève le PIC du circuit le LCD a la même attitude !
Non, tu places un point-virgule ( sur deux lignes de codes pour pouvoir assembler le programme...
C'est normal, l'init n'est pas bonne...si j'enlève le PIC du circuit le LCD a la même attitude !
David.
J'ai testé :
C'est pareil. Il clignote aléatoirement.
A+
C'est normal...
La modif que je t'ai demandé de faire "oublie" de modifier la ligne E du LCD, elle était cachée dans une autre routine...
Je viens seulement de le voir en étudiant correctement le code. Désolé...
Je vais te mettre en ligne une initialisation correcte, mais qui demande le remplacement de deux routines.
David.
Merci bien !
A +
Ce code est à placer en remplacement de "'lCdreset" et il faut supprimer totalement la routine "initwlcd"Code:;a whole bunCh of lCd routines to make life easier ; Représentation en mode 4bits : ; ; B'0011' premier MSB 8bits ; B'0011' deuxième MSB 8bits ; ; B'0011' troisième MSB 8bits ; B'0010' premier quartet de l'init Samsung en 4bits ; ; B'0010' Deuxième quartet de l'init Samsung en 4bits ; B'1100' troisième quartet de l'init Samsung en 2lignes, display on ; ; B'0000' premier quartet de l'init Samsung pour ecran, curseur ; B'1100' deuxième quartet de l'init samnsung pour écran on, curseur off et clignot off ; ; B'0000' premier quartet de l'init Samsung pour le clear ; B'0001' deuxième qurtet de l'init Samsung pour le clear ; ; B'0000' premier quartet de l'init Samansung pour gestion LCD ; B'0110' Deuxième quartet de l'init Sammsung pour incrémentation curseur sans shift ; ; Fin d'init lCdreset movlw d'50' Call wmilliseCs ;Attente 30ms suivant datasheet movlw b'00110011' ; 1MSB et 2MSB en huit bits (pour reset soft) call lCdCommand movlw d'2' Call wmilliseCs movlw b'00110010' ; 3MSB en huits bits et 1MSB en 4bits call lCdCommand movlw d'2' Call wmilliseCs movlw b'00101100' ; 2MSB en 4bits et 1LSB4 bits set 4 bit, 2 lines, 5x7 font call lCdCommand movlw d'2' Call wmilliseCs movlw b'00001100' ;display on, cursor off,blink off call lCdCommand movlw d'2' Call wmilliseCs call lCdClear ;clear lcd movlw d'2' Call wmilliseCs movlw b'00000110' ;increment cursor and no display shift call lCdCommand Boucle goto Boucle
Ce code à placer en remplacement de "lCdnibbles"Code:lCdnibbles movwf wlCdtemp ;save w! movlw d'1' Call _200useCs ;wait min. .2 ms (we don't read busy flag) bCf shadowb,lCde ;set e strobe low (default) movf wlCdtemp,w ;reCover original andlw b'11110000' ;just high bits first movwf nibbles ;save high nibbles movf shadowb,w ;get Control bits from flags andlw b'00001111' ; they are in lower 4 bits iorwf nibbles,w ;save result in w movwf PORTB ;output high bits and Controls... bsf PORTB,lCde ;begin enable strobe... nop ;add extra 1 us delay bCf PORTB,lCde ;end enable strobe ; ajout d'une pause pour compatibilité avec le reset movlw d'2' Call _200useCs ;wait min. .2 ms (we don't read busy flag) swapf wlCdtemp,f ;swap hi and lo nibbles of original movf wlCdtemp,w ;reCover swapped nibble andlw b'11110000' ;now low bits are in high bits movwf nibbles ;save this nibble (whiCh was low bits) movf shadowb,w ;get Control bits from flags andlw b'00001111' ; they are in lower 4 bits iorwf nibbles,w ;save result in w movwf PORTB ;output low bits... bsf PORTB,lCde ;begin enable strobe... nop ;slight delay bCf PORTB,lCde ;strobe e goes low now bsf shadowb,lCdrs ;default in flags is data mode bCf shadowb,lCde ;default in flags is strobe enable low swapf wlCdtemp,f ;baCk to normal... movf wlCdtemp,w ;we have w baCk! return
David.
D'accord je m'y mets !
;from here on out we use 4 bit interface!
;proper delays are built-in.
movlw b'00101000' ;set 4 bit, 2 lines, 5x7 font
call lcdcommand
movlw b'00001100' ;display on, cursor off,blink off
call lcdcommand
call lcdclear ;clear lcd
movlw b'00000110' ;increment cursor and no display shift
call lcdcommand
return
Est ce que ça fait partie de lcdreset ?
Ok c'est bon, ça n'en fait pas partie.
J'y vais pour le test !
Oui, le Lcdreset va jusqu'au RETURN, donc tu supprimes...
David.
Le test est fait :
1 - Le LCD ne clignote plus
2- Il semble ne pas être alimenté
Qu'en dis-tu ?
J'en dis que c'est bon!!!
Vire la boucle sans fin et test ton programme...
David.