Hello guys I'm interfacing LCD4bit mode & needs to display "Hello".
But I'm not getting anything.I have a code problem.
Note that LCD data lines are PORTC2,3,4,5
But I'm not getting anything.I have a code problem.
Note that LCD data lines are PORTC2,3,4,5
Code:
Main_Loop call LCD_Init
call LCD_Show
Wait_Here nop
goto Wait_Here
;LCD Lines
;------------------------------------------------------------------------------
;PORTC,2 = Data Line4
;PORTC,3 = Data Line5
;PORTC,4 = Data Line6
;PORTC,5 = Data Line7
;PORTC,6 = Register Select 1=Charctor Mode, 0=Command Mode
;PORTC,7 = Enable
;=================
;16X2 LCD Subroutines
;=================
;====================================================================
;LCD_Init = LCD Initialisation part
;====================================================================
LCD_Init clrf DelCount ; make count = 0
LCD_Settle call Delay_S ; settle the LCD at first
decfsz DelCount,F
goto LCD_Settle
movlw 20h ; b'00100000' set to 4 bit mode
call LCD_CMD_Write ; set to command mode
Func_Set movlw 28h ; 2 line display,5X8
call LCD_CMD_Write ; set to command mode
Disp_ON movlw b'00001100' ; Display on,
call LCD_CMD_Write
return
;====================================================================
;LCD_Show = shows current temperature on 16 X 2 line LCD
;====================================================================
LCD_Show movlw b'10000000' ; select 1st line at 00h
call LCD_CMD_Write ; set to command mode
Dis_Line1 movlw 'H'
call LCD_CHR_Write
movlw 'E'
call LCD_CHR_Write
movlw 'L'
call LCD_CHR_Write
movlw 'L'
call LCD_CHR_Write
movlw 'O'
call LCD_CHR_Write
return
;====================================================================
;LCD subroutines
;====================================================================
;PORTC,2 = Data Line4
;PORTC,3 = Data Line5
;PORTC,4 = Data Line6
;PORTC,5 = Data Line7
;PORTC,6 = Register Select 1=Charctor Mode, 0=Command Mode
;PORTC,7 = Enable
LCD_CMD_Write
movwf Temp
movf Temp,W ; get the value to be write
andlw 0F0h
movwf Temp1
bcf STATUS,C
rrf Temp1,F
bcf STATUS,C
rrf Temp1,W
iorwf PORTC,F
iorlw b'11000011'
andwf PORTC,F
bcf PORTC,6 ; RS line set to command mode
call Pulse_E
;
swapf Temp,W ; get the lower nibble
andlw 0F0h
movwf Temp1
bcf STATUS,C
rrf Temp1,F
bcf STATUS,C
rrf Temp1,W
iorwf PORTC,F
iorlw b'11000011'
andwf PORTC,F
bcf PORTC,6 ; RS line set to command mode
call Pulse_E ; make enable line trigger
call Delay_S
return
LCD_CHR_Write
movwf Temp
movf Temp,W ; get the value to be write
andlw 0F0h
movwf Temp1
bcf STATUS,C
rrf Temp1,F
bcf STATUS,C
rrf Temp1,W
iorwf PORTC,F
iorlw b'11000011'
andwf PORTC,F
bsf PORTC,6 ; RS line set to charactor mode
call Pulse_E ; make enable line trigger
;
swapf Temp,W ; get the lower nibble
andlw 0F0h
movwf Temp1
bcf STATUS,C
rrf Temp1,F
bcf STATUS,C
rrf Temp1,W
iorwf PORTC,F
iorlw b'11000011'
andwf PORTC,F
bsf PORTC,6 ; RS line set to charactor mode
call Pulse_E ; make enable line trigger
call Delay_S
return
Pulse_E bsf PORTC,7 ; trigger to make active Enable
nop
bcf PORTC,7
return
Delay_S movlw .5
movwf Del2
decfsz Del1,F ; 770uS delay time
goto $-1
decfsz Del2,F
goto $-3
return
Last edited: