;Datos del LCD en los 4 bits menos significativos del puerto b
#define LCD_E PORTA,0 ;pin de enable
#define LCD_RS PORTA,1 ;pin de selección de comando o caracter
;Configuración incial del LCD.
IniLcd bcf LCD_RS
bcf LCD_E
call Delay
movlw b'00000011' ;se envia 4 veces configuracion para 8 bits
call EnvLcd ;EnvLcd envia solo el nibble bajo.
movlw b'00000011'
call EnvLcd
movlw b'00000011'
call EnvLcd
movlw b'00000011'
call EnvLcd
movlw b'00000010' ;LCD en modo 4 bits
call EnvLcd
movlw b'00101000' ;4 bits y dos lineas
call Lcd_Com ;Lcd_com envia 8 bits en 2 paquetes de 4 bits
movlw b'00000110' ;LCD: Informacion no se desplaza, incremento del cursor
call Lcd_Com
movlw b'00001111' ;Cursor visible e intermitente
call Lcd_Com
movlw b'00000001' ;Borra pantalla y va home
call Lcd_Com
return
;Envia caracter al LCD en modo 4 bits: se envía primero el nibble mas significativo.
Lcd_Char bsf LCD_RS ;RS = 1 caracter
Lcd_Com movwf Nibble
swapf Nibble,w ;intercambia nibbles y guarda en w
andlw 0x0f
call EnvLcd
movf Nibble,w
andlw 0x0f
call EnvLcd
bcf LCD_RS
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EnvLcd clrwdt
movwf PORTB
bsf LCD_E
call Del_40us
bcf LCD_E
btfss LCD_RS
call Delay ;si es comando-> 5 mS