;===============================================================================================
; Subroutine Name : init_lcd
; Purpose : Initialise LCD for 4 Bit Communication
; Input : Nil
; Output : Nil
;===============================================================================================
init_lcd:
;function set:
;
ldi temp, 15
rcall com_wt ; wait for 15ms after power on reset
ldi temp, 0b00000011 ;
rcall lcd_out
;function set:
ldi temp ,5
rcall com_wt
ldi temp, 0b00000011
rcall lcd_out
;function set
rcall delay_micros
rcall delay_micros
ldi temp,0b00000011
rcall lcd_out
ldi temp,5
rcall com_wt
;function set for 4 bit mode 2lines and 5x7 font size
ldi temp,0b00000010
rcall lcd_out
rcall delay_micros
ldi temp,0x28;0b00001100
rcall com_out;lcd_out
ldi temp,2
rcall com_wt
;cursor/display shift: shift the cursor position to right
ldi temp , 0b00010100
rcall com_out
rcall delay_micros
;display on/off mode
ldi temp , 0b00001100
rcall com_out
rcall delay_micros
;entry mode
ldi temp , 0b00000110
rcall com_out
rcall delay_micros
;clr display
ldi temp , 0b00000001
rcall com_out
ldi temp , 2
rcall com_wt
ret
;===============================================================================================
; Subroutine Name : com_out
; Purpose : To send command word to LCD by 4 bit communication
; Input : temp (Register)
; Output : Nil
; Registers Used : temp, temp1
;===============================================================================================
com_out:
push temp
swap temp
andi temp,0b00001111
ori temp,0b00000000
rcall lcd_out
pop temp
andi temp,0b00001111
ori temp,0b00000000
rcall lcd_out
rcall delay_micros
ret
;===============================================================================================
; Subroutine Name : lcd_out
; Purpose : To send 1 Byte data to LCD by 4 bit commmunication
; Input : temp (Register)
; Output : Nil
; Registers Used : temp, temp1
;===============================================================================================
lcd_out:
in temp1,portc
andi temp1,0b11000000
or temp,temp1
out portc,temp
sbi portc,lcd_en
nop
cbi portc,lcd_en
ret