; 08 nov 2003 OK pour 628REGUL.pjt ; rev 26 janv 2003 lcd4c.inc ; fichiers liés: delais_b.inc lcd4c.h ; routines en mode 4 Bits avec afficheur 2*16 à base de HD77480 ; LCD_Init : initialisation de l'afficheur ; LCD_Putchar : envoi un caractere ( contenu dans w ) sur l'afficheur ; LCD_Cde : envoi une commande ( contenue dans w) à l'afficheur ; LCD_Cls : efface l'afficheur ; LCD_Clear1 : efface la premiere ligne de l'afficheur ; LCD_Clear2 : efface la deuxieme ligne de l'afficheur ; LCD_Home : renvoi le curseur en haut a gauche ; LCD_Line1 : renvoi le curseur au debut de la ligne 1 ; LCD_Line2 : renvoi le curseur au debut de la ligne 2 ; pour positionner le curseur sur la ligne 1 : movlw 0x80+offset call LCD_Cde ; pour positionner le curseur sur la ligne 2 : movlw 0xC0+offset call LCD_Cde ; ; variables a definir dans le programme principal: ; LCDtmp,LCDTmp1 ; LCD ; ; constantes a definir dans le programme principal: ; LCD_DATA EQU PORTB ; LCD: Port ou est branche le bus de donnee ( bits 4 à 7 ) ; LCD_DATA_TRIS EQU TRISB ; LCD: Port ou est branche le bus de donnee ( bits 4 à 7 ) ; LCD_CTRL EQU PORTA ; LCD: Port ou est branche le bus de commande ; LCD_CTRL_TRIS EQU TRISA ; LCD: Port ou est branche le bus de commande ; LCD_E EQU 1 ; LCD: Ligne de commande de controle de l'afficheur ;not used LCD_RW EQU 1 ; LCD: Ligne de Lecture/Ecriture de l'afficheur ; LCD_RS EQU 0 ; LCD: Ligne de selection de l'afficheur ; ; IMPORTANT : ce programme est optimisé --> ne pas changer l'ordre des commandes LCD_Cls movlw D'01' ; effacage de l'ecran call LCD_Cde goto delay_2_5ms ;----------------- LCD_Clear1 ; effacage de la 1ere ligne movlw D'16' movwf LCDtmp1 movlw LINE1 ; 0x80 call LCD_Cde call delay_2_5ms LCDc111 movlw ' ' call LCD_Putchar decfsz LCDtmp1,f goto LCDc111 LCD_Line1 movlw LINE1 call LCD_Cde goto delay_2_5ms ;-------------- LCD_Clear2 ; effacage de la deuxieme ligne movlw D'16' movwf LCDtmp1 movlw LINE2 ; 0xC0 call LCD_Cde call delay_2_5ms LCDcl21 movlw ' ' call LCD_Putchar decfsz LCDtmp1,f goto LCDcl21 LCD_Line2 movlw LINE2 call LCD_Cde goto delay_2_5ms LCD_Home movlw D'02' call LCD_Cde goto delay_2_5ms LCD_Putchar bank0 ; rajout 7/03/03 movwf LCDtmp call delay_1ms movlw 0x0f andwf LCD_DATA,F movf LCDtmp,w andlw 0xF0 iorwf LCD_DATA,F ; bcf LCD_CTRL, LCD_RW nop bsf LCD_CTRL, LCD_RS nop bsf LCD_CTRL, LCD_E call delay_25us bcf LCD_CTRL, LCD_E call delay_25us movlw 0x0f andwf LCD_DATA,F swapf LCDtmp,W andlw 0xF0 iorwf LCD_DATA,F nop bsf LCD_CTRL, LCD_E call delay_25us bcf LCD_CTRL, LCD_E call delay_25us return LCD_Init bcf LCD_CTRL, LCD_E nop bcf LCD_CTRL, LCD_RS nop ; bcf LCD_CTRL, LCD_RW call delay_2_5ms movlw 0x0f andwf LCD_DATA,F movlw 0x030 ; Commande pour interface 4 bits iorwf LCD_DATA,F bank1 movlw 0x0F andwf LCD_DATA_TRIS,W movwf LCD_DATA_TRIS ; Port en sortie bank0 bsf LCD_CTRL, LCD_E nop bcf LCD_CTRL, LCD_E call delay_2_5ms bsf LCD_CTRL, LCD_E nop bcf LCD_CTRL, LCD_E call delay_2_5ms bsf LCD_CTRL, LCD_E nop bcf LCD_CTRL, LCD_E call delay_100ms ; tempo 100ms , remplace l'attente Wait_Busy de l'afficheur movlw 0x0f andwf LCD_DATA,F movlw 0x020 ; Commande pour interface 4 bits iorwf LCD_DATA,F bsf LCD_CTRL, LCD_E nop bcf LCD_CTRL, LCD_E movlw 0x028 ; Envoi de la commande Fonction 4-bit , Font, Nombre de lignes call LCD_Cde movlw 0x008 ; display off call LCD_Cde movlw 0x00C ; display on (0x00C sans curseur, 0x00E avec , 0x00F clign. ) call LCD_Cde movlw 0x006 LCD_Cde movwf LCDtmp call delay_100ms ; tempo 100ms , remplace l'attente Wait_Busy de l'afficheur movlw 0x0f andwf LCD_DATA,F movf LCDtmp,w andlw 0xF0 iorwf LCD_DATA,F ; bcf LCD_CTRL,LCD_RW nop bcf LCD_CTRL,LCD_RS nop bsf LCD_CTRL,LCD_E nop bcf LCD_CTRL,LCD_E movlw 0x0f andwf LCD_DATA,F swapf LCDtmp,W andlw 0xF0 iorwf LCD_DATA,F bsf LCD_CTRL,LCD_E nop bcf LCD_CTRL,LCD_E return