How to change this code to work for 16f88
Code:
; Program "LCD.ASM"
title "LCD"
processor 16F84a
include p16f84a.inc
__config _PWRTE_OFF & _WDT_OFF & _XT_OSC
radix DEC
errorlevel -302
#define E PORTB,3
#define RS PORTB,2
#define DATA_PORT PORTB ; Only of RB7 … RB4
#define DATA_DIR TRISB
cblock h'0C'
SaveW
Char
Temp
Temp1
Temp2
Temp3
Temp4
Result : 4 ; MSB first
Thousand : 2 ; MSB first
BCD0
BCD1
BCD2
BCD3
N
endc
org 0
goto START
ClearDisp macro
movlw b'00000001'
call SEND_CMD
call T1mS ; To erase the screen takes more 1mS
endm
DataOk macro ; Validation of the data
bsf E
bcf E
endm
DDRam macro address
movlw 0x80 + address
call SEND_CMD
endm
Disp macro charvalue
movlw charvalue
call SEND_CHAR
endm
RSCmd macro ; The data are orders (RS=0)
bcf RS
endm
RSChar macro ; The data are characters (RS=1)
bsf RS
endm
ShiftL macro ; Decalage towards the left of posting
movlw b'00011000'
call SEND_CMD
endm
;________________________________Subroutines________________________________
; Delays 1mS, 10mS, 100mS and 1S
T1mS
movwf SaveW
movlw .248
movwf Temp1
Loop1mS
nop
decfsz Temp1,f
goto Loop1mS
movf SaveW,w
return
;
T10mS
movwf SaveW
movlw .10
movwf Temp2
Loop10mS
call T1mS
decfsz Temp2,f
goto Loop10mS
movf SaveW,w
return
;
T100mS
movwf SaveW
movlw .100
movwf Temp3
Loop100mS
call T1mS
decfsz Temp3,f
goto Loop100mS
movf SaveW,w
return
;
T1S
movwf SaveW
movlw .100
movwf Temp4
Loop1S
call T10mS
decfsz Temp4,f
goto Loop1S
movf SaveW,w
;---------------------------------------------------------------------------
; Description: Transmet un caractere vers l'afficheur
; Entr‚e: Caractere dans le registre W
; Sortie: Aucune
SEND_CHAR
call T1mS ; Attendre que l'afficheur soit pret
RSChar ; Afficheur en mode caract‚re
movwf Char ; Sauvegarde du caract‚re
movf DATA_PORT,w
andlw 0x0F
movwf DATA_PORT
; Masquage: Reset du poids fort de DP
movf Char,W ; On restaure le caract‚re dans W
andlw 0xF0 ; On isole le poids fort du registre W
iorwf DATA_PORT,F ; On positionne le poids fort de DATA_PORT
DataOk ; On bascule le verrou du LCD
swapf Char,F ; On ‚change les poids fort et faible
movf DATA_PORT,w
andlw 0x0F
movwf DATA_PORT
; Masquage: Reset du poids fort de DP
movf Char,W
andlw 0xF0 ; On isole le poids fort du registre W
iorwf DATA_PORT,F ; On positionne le poids fort de DATA_PORT
DataOk ; On bascule le verrou du LCD
retlw 0 ; Retour avec W=0
;-----------------------------------------------------------------------------
; Description: Transmet une commande vers l'afficheur
; Entree: Commande dans le registre W
; Sortie: Aucune
SEND_CMD
call T1mS ; Attendre que l'afficheur soit prˆt
RSCmd ; Afficheur en mode commande
movwf Char ; Sauvegarde de la commande
movf DATA_PORT,w
andlw 0x0F
movwf DATA_PORT
; Masquage: Reset du poids fort de DP
movf Char,W ; On restaure la commande dans W
andlw 0xF0 ; On isole le poids fort du registre W
iorwf DATA_PORT,F ; On positionne le poids fort de DATA_PORT
DataOk ; On bascule le verrou du LCD
swapf Char,F ; On ‚change les poids fort et faible
movf DATA_PORT,w
andlw 0x0F
movwf DATA_PORT
; Masquage: Reset du poids fort de DP
movf Char,W
andlw 0xF0 ; On isole le poids fort du registre W
iorwf DATA_PORT,F ; On positionne le poids fort de DATA_PORT
DataOk ; On bascule le verrou du LCD
retlw 0 ; Retour avec W=0
;____________________________________main___________________________________
START
bsf STATUS,RP0
movlw B'00000000'
movwf TRISB
bcf STATUS,RP0
clrf PORTB
call INIT_LCD
movlw b'00001100'
call SEND_CMD
movlw b'00101000'
call SEND_CMD
ClearDisp
Disp 'F'
Disp 'R'
Disp 'E'
call T1S
ClearDisp
end
Last edited: