1
#include "P16F877A.inc"
7
temp EQU 0x20 ;temp variable
17
CLRWDT ;clear the watch dog timer
18
;watch dog timer restart the program if it overflowed
19
call init_port_d_output
35
;The first three pins as output
41
movlw b'00001111' ;Digital mode for port E
42
movwf ADCON1 ;read page 114 of the datasheet
44
bcf TRISE,RS ;initialize pin0 to output
45
bcf TRISE,RW ;initialize pin1 to output
46
bcf TRISE,E ;initialize pin2 to output
49
;PORTD will be used as an input to the LCD data bus
51
bsf STATUS,5 ;choose bank 01
52
bcf STATUS,6 ;RP0,RP1 from status =01m
59
;PORTD will be used as an input to read the LCD status
62
movlw 0xFF ;make PORTD as input
67
call init_port_d_output
68
call busy_LCD ;check if the LCD busy
73
bcf PORTE,RW ;R/W -->0
82
;check if the LCD is busy
83
call init_port_d_input ; to read the LCD status
91
movf PORTD,W ;flag busy ?
99
;send a char to the LCD
100
;the char must be stored in working register
103
movwf temp ;moving the WREG contents to a temp variable
104
;WREG will be overwritten
105
call busy_LCD ;check if the LCD busy
107
call init_port_d_output
109
bsf PORTE,RS ;control signals
114
movf temp,W ;sending the stored character to PORTD
145
call init_port_d_output
156
call init_port_d_output
163
movlw b'00111100' ;b3=1-> 2-line mode
171
movlw b'00001111' ;b2=1-> Display on
181
movlw b'00000111' ;b1=1-> increment on
b'\\ No newline at end of file'