LCDInit: BCF PORTA,0; CONTROL SIGNAL TO RS
BCF PORTA,1; CONTROL SIGNAL TO R/W
BSF PORTA,2; CONTROL SIGNAL TO 'E'
MOVLW 0x0F
MOVWF PORTB
CALL DISPLAY
MOVLW 'H'
CALL DISPLAY
MOVLW 'E'
CALL DISPLAY
MOVLW 'L'
CALL DISPLAY
MOVLW 'L'
CALL DISPLAY
MOVLW 'O'
CALL DISPLAY
MOVLW ' '
CALL DISPLAY
MOVLW 'W'
CALL DISPLAY
MOVLW 'E'
CALL DISPLAY
MOVLW 'L'
CALL DISPLAY
MOVLW 'C'
CALL DISPLAY
MOVLW 'O'
CALL DISPLAY
MOVLW 'M'
CALL DISPLAY
MOVLW 'E'
CALL DISPLAY
MOVLW ' '
CALL DISPLAY
BCF PORTA,0;LCD INPUT=>INSTRUCTION
MOVLW 0x01
MOVWF PORTB
CALL DISPLAY
RETURN
DISPLAY:
MOVWF PORTB
BCF PORTA,2
BSF PORTA,2
CALL DELY
BSF PORTA,0
RETURN
DELY MOVLW D'13'
MOVWF T1
MOVLW D'251'
MOVWF T2
LP DECFSZ T2,1
GOTO LP
DECFSZ T1,1
GOTO LP
RETURN
; RECEIVER LOGIC PROGRAM
LIST P=18F4550, F=INHX32 ;directive to define processor
#include <P18F4550.INC> ;processor specific variable definitions
T1 EQU 0X057
T2 EQU 0X59
CONFIG WDT=OFF ; disable watchdog timer
CONFIG MCLRE = ON ; MCLEAR Pin on
CONFIG DEBUG = OFF ; Enable Debug Mode
CONFIG LVP = OFF ; Disable low voltage programming
CONFIG FOSC = INTOSCIO_EC ; internal oscillator
CONFIG PBADEN = OFF ; PORTB all digital
;Reset vector
; This code will start executing when a reset occurs.
RESET_VECTOR CODE 0x0000
goto Start
Start:
CLRF WREG
CLRF RCSTA
CLRF PORTA
CLRF TRISA
CLRF PORTB
CLRF TRISB
MOVLW 0X06
MOVWF ADCON1
CALL LCDInit ; LCD Display Initialization
LCDInit: BCF PORTA,0; CONTROL SIGNAL TO RS
BCF PORTA,1; CONTROL SIGNAL TO R/W
BSF PORTA,2; CONTROL SIGNAL TO 'E'
MOVLW 0x0F
MOVWF PORTB
CALL DISPLAY
MOVLW 'H'
CALL DISPLAY
MOVLW 'E'
CALL DISPLAY
MOVLW 'L'
CALL DISPLAY
MOVLW 'L'
CALL DISPLAY
MOVLW 'O'
CALL DISPLAY
MOVLW ' '
CALL DISPLAY
MOVLW 'W'
CALL DISPLAY
MOVLW 'E'
CALL DISPLAY
MOVLW 'L'
CALL DISPLAY
MOVLW 'C'
CALL DISPLAY
MOVLW 'O'
CALL DISPLAY
MOVLW 'M'
CALL DISPLAY
MOVLW 'E'
CALL DISPLAY
MOVLW ' '
CALL DISPLAY
BCF PORTA,0;LCD INPUT=>INSTRUCTION
MOVLW 0x01
MOVWF PORTB
CALL DISPLAY
RETURN
DISPLAY:
MOVWF PORTB
BCF PORTA,2
BSF PORTA,2
CALL DELY
BSF PORTA,0
RETURN
DELY MOVLW D'13'
MOVWF T1
MOVLW D'251'
MOVWF T2
LP DECFSZ T2,1
GOTO LP
DECFSZ T1,1
GOTO LP
RETURN
END
On your hardware are you using the USB cap ( simulation probably would assume it for you)
My OSCCON register is 44, which means 1MHz stable frequency. What is the difference with 8 bit mode? is it more difficult? Can you suggest any site which gives exact initialization routine for 8 bit mode? I tried many but all failed.
I didn't understand this
I still can't get it right. I was following the instructions in to interface the LCD. It says just give the command 0x0F and the cursor will start blinking. Then we can give any character to be displayed and the LCD will display it. All I see is solid boxes and I cannot vary the contrast also.
Hi,
Attached is a proven routine I have just simulated ok using your config lines and the circuit shown.
It uses 4 bit mode with a 4 mhz internal oscillator.
MOVLW 0X06
MOVWF ADCON1
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?