Accueil > > > AFFICHEUR LCD 2X16 EN MODE 8BIT POUR PIC 16XXX
AFFICHEUR LCD 2X16 EN MODE 8BIT POUR PIC 16XXX
Information sur la source
Description
Voici les routines nécessaires pour faire marcher simplement un afficheur LCD en mode 8bit. Type de pic : PIC16FXXX (ou 16CXXX) Quartz : 4Mhz (pour utiliser un autre quartz, il suffit de modifier le fichier q4mhz.asm qui contient les routines de temporisation).
Source
- ;
- ; Routines afficheur 2*16 en mode 8 Bits V1.0a
- ;
- ; O.R 05/2003
- ;-----------------------------------------------------------------------------------------
- ;
- ;
- ; LCD_INIT : initialisation de l'afficheur
- ; LCD_WRITE_RAM_W : envoi un caractere ( contenu dans w ) sur l'afficheur
- ; LCD_WRITE_CONTROL_W : envoi une commande ( contenue dans w) à l'afficheur
- ; LCD_CLEAR_DISPLAY : efface l'afficheur
- ; LCD_RETURN_HOME : renvoi le curseur en haut a gauche
- ; LCD_LIGNE1 : renvoi le curseur au debut de la ligne 1
- ; LCD_LIGNE2 : renvoi le curseur au debut de la ligne 2
- ; LCD_ON/LCD_OFF : allume ou eteint l'affichage
- ; LCD_CURSOR_ON/LCD_CURSOR_OFF : Affichage ou pas du curseur
- ; LCD_BLINK_ON/LCD_BLINK_OFF : Mode BLINK on ou off
- ; LCD_DIR_LEFT/LCD_DIR_RIGHT : Direction de l'écriture
- ; LCD_SH_ON/LCD_SH_OFF :
- ;
- ; constantes a definir dans le programme principal:
- ;
- ; LCD_DATA ; LCD: Port ou est branche le bus de donnee ( bits 0 à 7 )
- ; LCD_E ; LCD: Ligne de commande de controle de l'afficheur
- ; LCD_RW ; LCD: Ligne de Lecture/Ecriture de l'afficheur
- ; LCD_RS ; LCD: Ligne de selection de l'afficheur
- ;
- ; variables a definir dans le programme principal:
- ;
- ; LCD_mode_set, LCD_disp_cont,DATA_TMP,J
- ; LCD_curs_disp_shift, LCD_func_set
- ;
-
- LCD_INIT: ;Initialisation de l'afficheur
-
- CALL Tempo_30ms
- movlw LCD_FUNCTION_SET ;Function set
- movwf LCD_func_set ;Sauvegarde des paramètres
- call LCD_WRITE_CONTROL_W ;Ecriture
- ;Tempo de 39us
-
- movlw LCD_DISPLAY_CONTROL ;Display ON/OFF
- movwf LCD_disp_cont ;Sauvegarde des paramètres
- call LCD_WRITE_CONTROL_W ;Ecriture
- ;Tempo de 39us
-
- call LCD_CLEAR_DISPLAY
-
- movlw LCD_ENTRY_MODE_SET ;Entry mode set
- movwf LCD_mode_set ;Sauvegarde des paramètres
- call LCD_WRITE_CONTROL_W ;Ecriture
- CALL Tempo_43us
-
- movlw LCD_CURSOR_DISPLAY_SHIFT
- movwf LCD_curs_disp_shift ;Sauvegarde des paramètres
-
- return ;Init end
-
- LCD_WRITE_CONTROL_W:
- bcf LCD_RW ;Write
- bcf LCD_RS ;RS a 0
- bsf LCD_E ;Enable a 1
- movwf LCD_DATA ;Copie W sur le bus DATA
- bcf LCD_E ;Enable a 0
- CALL Tempo_43us
- return
-
- LCD_WRITE_RAM_W:
- bcf LCD_RW ;Write
- bsf LCD_RS ;RS a 1
- bsf LCD_E ;Enable a 1
- movwf LCD_DATA ;Copie W sur le bus DATA
- bcf LCD_E ;Enable a 0
- CALL Tempo_43us
- return
-
- LCD_SET_CGRAM_ADD:
- movlw h'40'
- bcf LCD_RW ;Write
- bcf LCD_RS ;RS a 0
- bsf LCD_E ;Enable a 1
- movwf LCD_DATA ;Copie W sur le bus DATA
- bcf LCD_E ;Enable a 0
- CALL Tempo_43us
- return
-
- LCD_SET_DDRAM_ADD:
- movlw h'80'
- bcf LCD_RW ;Write
- bcf LCD_RS ;RS a 0
- bsf LCD_E ;Enable a 1
- movwf LCD_DATA ;Copie W sur le bus DATA
- bcf LCD_E ;Enable a 0
- CALL Tempo_43us
- return
-
- LCD_LIGNE1:
- movlw h'80'
- CALL LCD_WRITE_CONTROL_W
- return
-
- LCD_LIGNE2:
- movlw h'C0'
- CALL LCD_WRITE_CONTROL_W
- return
-
- LCD_CLEAR_DISPLAY:
- movlw h'01'
- CALL LCD_WRITE_CONTROL_W
- CALL Tempo_1530us
- return
-
- LCD_RETURN_HOME:
- movlw h'02'
- CALL LCD_WRITE_CONTROL_W
- CALL Tempo_1530us
- return
-
- LCD_ON:
- bsf LCD_disp_cont,2
- movf LCD_disp_cont,0
- CALL LCD_WRITE_CONTROL_W
- return
-
- LCD_OFF:
- bcf LCD_disp_cont,2
- movf LCD_disp_cont,0
- CALL LCD_WRITE_CONTROL_W
- return
-
- LCD_CURSOR_ON:
- bsf LCD_disp_cont,1
- movf LCD_disp_cont,0
- CALL LCD_WRITE_CONTROL_W
- return
-
- LCD_CURSOR_OFF:
- bcf LCD_disp_cont,1
- movf LCD_disp_cont,0
- CALL LCD_WRITE_CONTROL_W
- return
-
- LCD_BLINK_ON:
- bsf LCD_disp_cont,0
- movf LCD_disp_cont,0
- CALL LCD_WRITE_CONTROL_W
- return
-
- LCD_BLINK_OFF:
- bcf LCD_disp_cont,0
- movf LCD_disp_cont,0
- CALL LCD_WRITE_CONTROL_W
- return
-
- LCD_DIR_LEFT:
- bcf LCD_mode_set,1
- movf LCD_mode_set,0
- CALL LCD_WRITE_CONTROL_W
- return
-
- LCD_DIR_RIGHT:
- bsf LCD_mode_set,1
- movf LCD_mode_set,0
- CALL LCD_WRITE_CONTROL_W
- return
-
- LCD_SH_ON:
- bsf LCD_mode_set,2
- movf LCD_mode_set,0
- CALL LCD_WRITE_CONTROL_W
- return
-
- LCD_SH_OFF:
- bcf LCD_mode_set,2
- movf LCD_mode_set,0
- CALL LCD_WRITE_CONTROL_W
- return
-
-
-
;
; Routines afficheur 2*16 en mode 8 Bits V1.0a
;
; O.R 05/2003
;-----------------------------------------------------------------------------------------
;
;
; LCD_INIT : initialisation de l'afficheur
; LCD_WRITE_RAM_W : envoi un caractere ( contenu dans w ) sur l'afficheur
; LCD_WRITE_CONTROL_W : envoi une commande ( contenue dans w) à l'afficheur
; LCD_CLEAR_DISPLAY : efface l'afficheur
; LCD_RETURN_HOME : renvoi le curseur en haut a gauche
; LCD_LIGNE1 : renvoi le curseur au debut de la ligne 1
; LCD_LIGNE2 : renvoi le curseur au debut de la ligne 2
; LCD_ON/LCD_OFF : allume ou eteint l'affichage
; LCD_CURSOR_ON/LCD_CURSOR_OFF : Affichage ou pas du curseur
; LCD_BLINK_ON/LCD_BLINK_OFF : Mode BLINK on ou off
; LCD_DIR_LEFT/LCD_DIR_RIGHT : Direction de l'écriture
; LCD_SH_ON/LCD_SH_OFF :
;
; constantes a definir dans le programme principal:
;
; LCD_DATA ; LCD: Port ou est branche le bus de donnee ( bits 0 à 7 )
; LCD_E ; LCD: Ligne de commande de controle de l'afficheur
; LCD_RW ; LCD: Ligne de Lecture/Ecriture de l'afficheur
; LCD_RS ; LCD: Ligne de selection de l'afficheur
;
; variables a definir dans le programme principal:
;
; LCD_mode_set, LCD_disp_cont,DATA_TMP,J
; LCD_curs_disp_shift, LCD_func_set
;
LCD_INIT: ;Initialisation de l'afficheur
CALL Tempo_30ms
movlw LCD_FUNCTION_SET ;Function set
movwf LCD_func_set ;Sauvegarde des paramètres
call LCD_WRITE_CONTROL_W ;Ecriture
;Tempo de 39us
movlw LCD_DISPLAY_CONTROL ;Display ON/OFF
movwf LCD_disp_cont ;Sauvegarde des paramètres
call LCD_WRITE_CONTROL_W ;Ecriture
;Tempo de 39us
call LCD_CLEAR_DISPLAY
movlw LCD_ENTRY_MODE_SET ;Entry mode set
movwf LCD_mode_set ;Sauvegarde des paramètres
call LCD_WRITE_CONTROL_W ;Ecriture
CALL Tempo_43us
movlw LCD_CURSOR_DISPLAY_SHIFT
movwf LCD_curs_disp_shift ;Sauvegarde des paramètres
return ;Init end
LCD_WRITE_CONTROL_W:
bcf LCD_RW ;Write
bcf LCD_RS ;RS a 0
bsf LCD_E ;Enable a 1
movwf LCD_DATA ;Copie W sur le bus DATA
bcf LCD_E ;Enable a 0
CALL Tempo_43us
return
LCD_WRITE_RAM_W:
bcf LCD_RW ;Write
bsf LCD_RS ;RS a 1
bsf LCD_E ;Enable a 1
movwf LCD_DATA ;Copie W sur le bus DATA
bcf LCD_E ;Enable a 0
CALL Tempo_43us
return
LCD_SET_CGRAM_ADD:
movlw h'40'
bcf LCD_RW ;Write
bcf LCD_RS ;RS a 0
bsf LCD_E ;Enable a 1
movwf LCD_DATA ;Copie W sur le bus DATA
bcf LCD_E ;Enable a 0
CALL Tempo_43us
return
LCD_SET_DDRAM_ADD:
movlw h'80'
bcf LCD_RW ;Write
bcf LCD_RS ;RS a 0
bsf LCD_E ;Enable a 1
movwf LCD_DATA ;Copie W sur le bus DATA
bcf LCD_E ;Enable a 0
CALL Tempo_43us
return
LCD_LIGNE1:
movlw h'80'
CALL LCD_WRITE_CONTROL_W
return
LCD_LIGNE2:
movlw h'C0'
CALL LCD_WRITE_CONTROL_W
return
LCD_CLEAR_DISPLAY:
movlw h'01'
CALL LCD_WRITE_CONTROL_W
CALL Tempo_1530us
return
LCD_RETURN_HOME:
movlw h'02'
CALL LCD_WRITE_CONTROL_W
CALL Tempo_1530us
return
LCD_ON:
bsf LCD_disp_cont,2
movf LCD_disp_cont,0
CALL LCD_WRITE_CONTROL_W
return
LCD_OFF:
bcf LCD_disp_cont,2
movf LCD_disp_cont,0
CALL LCD_WRITE_CONTROL_W
return
LCD_CURSOR_ON:
bsf LCD_disp_cont,1
movf LCD_disp_cont,0
CALL LCD_WRITE_CONTROL_W
return
LCD_CURSOR_OFF:
bcf LCD_disp_cont,1
movf LCD_disp_cont,0
CALL LCD_WRITE_CONTROL_W
return
LCD_BLINK_ON:
bsf LCD_disp_cont,0
movf LCD_disp_cont,0
CALL LCD_WRITE_CONTROL_W
return
LCD_BLINK_OFF:
bcf LCD_disp_cont,0
movf LCD_disp_cont,0
CALL LCD_WRITE_CONTROL_W
return
LCD_DIR_LEFT:
bcf LCD_mode_set,1
movf LCD_mode_set,0
CALL LCD_WRITE_CONTROL_W
return
LCD_DIR_RIGHT:
bsf LCD_mode_set,1
movf LCD_mode_set,0
CALL LCD_WRITE_CONTROL_W
return
LCD_SH_ON:
bsf LCD_mode_set,2
movf LCD_mode_set,0
CALL LCD_WRITE_CONTROL_W
return
LCD_SH_OFF:
bcf LCD_mode_set,2
movf LCD_mode_set,0
CALL LCD_WRITE_CONTROL_W
return
Conclusion
Première étape indispensable : passer par un call LCD_INIT pour initialiser l'écran. Ensuite pour écrire un caractère, rien de plus simple :
movlw d'41' (A en ascii) call LCD_WRITE_RAM_W
et c tout !
le fichier lcd_8b.inc contient toutes les données d'initialisations.
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
code pour testé afficheur Lcd 4 lignes en 8bits [ par fujifilm ]
Bonjour,J'aimerais testé un afficheur LCD solomon LM1100 4 lignes en 8bits avec un hc12, où je peux trouver ce genre de chose, le tout en assembleur.M
EditBox [ par Bros ]
SalutJ'ai une fenetre avec un editbox.Mon programme ouvre un fichier et va afficher dans l'édit box: "Fichier ouvert..."En suite a la ligne en dessous
Afficher une image / MSDOS [ par frolow ]
FrölöwBonjours Ô programmeur!J'aurai besoin d'une source qui m'expliquerai comment d'une part afficher une image à l'écran sous msdos. Mais aussi comm
communication par liaison rs232 vers LCD graphic [ par lcoumar ]
Bonjours!voilà je suis débutant en asembleur, j'envoie d'un pc des chaines de caractère vers un afficheur LCD graphic(type hitachi LMG6912)via la liai
affichage lcd et calculatrice [ par lefrans ]
bojour a tous voila mon probleme je doit tj faire cette calculatrice et je suis bloqué, je narrive pas a afficher plusieur chiffre ala suite sur mon l
affichage du contenu d'un registre général [ par did2604 ]
Bonsoir,Quel est le code qui permet d'afficher le contenu d'un registre général (bx par exemple). Exemple, le registre BX contient la valeur 3F8 et j'
Afficher un pixel [ par S2R ]
Bonjour, je voudrait savoir comment afficher un pixel à l'écran sans passer par les interruptions, en mode vidéo 12h.j'ai trouvé une fonction, mais el
Affichage texte (Debutant) [ par ffomnislash ]
BonjourJe debute en assembleur et je voudrais pouvoir afficher du texte en boucle, ceci j'y arrive sans pb mais le texte se rajouteAutrement dit j'ai
tasm, couleurs 32bits ou 24bits? [ par qbced ]
Lu all! J'me suis mit à la prog asm, la j'arrive à afficher une image en 800*600*32bits, mais mon prob c'est que la plage memoire pour un pixel est de
coprocesseur math flottant [ par psion2 ]
voilà je dois afficher le resultat obtenu dans le coprocesseur math, j'ai lu plusieurs solutions dans le forum mais je ne les comprends pas totalement
|
Derniers Blogs
COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE?COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE? par Matthieu MEZIL
Avec EF, les vues doivent être mappées sur des entity types. Le problème c'est que les entity types doivent avoir une clé. Avec EF, nous avons les complex type qui n'ont pas de clé mais les vues ne peuvent pas être mappées dessus. Avec EF4, il est possibl...
Cliquez pour lire la suite de l'article par Matthieu MEZIL [WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ?MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ? par junarnoalg
La prochaine session de MyTIC aura lieu à Namur, le 23 mars prochain. Pendant presque une heure, nous parlerons de SharePoint 2010. Voici un aperçu du programme.
Accueil : 17h30 Début de la session : 18h00 - Les nouvelles int...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
RE : ASSEMBLEURRE : ASSEMBLEUR par solleil
Cliquez pour lire la suite par solleil RE : ASSEMBLEURRE : ASSEMBLEUR par ghuysmans99
Cliquez pour lire la suite par ghuysmans99
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|