|
begin process at 2008 08 20 19:13:11
Derniers logiciels
|
Trouver une ressource (Nouvelle version du moteur, plus rapide & pertinent, essayez le !)
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
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.
Fichier Zip
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
Télécharger le zip
Sources de la même categorie
Commentaires
Discussions en rapport avec ce code source
|
CalendriCode
| | | L | M | M | J | V | S | D |
| | | | | 1 | 2 | 3 |
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
|
Téléchargements
Logiciels à télécharger sur le même thème :
|
|