vishy71
Full Member level 2
hi there!
I have writen a code for use LCD in 4 bit mode!
It's wrong but I don't know what!please help!
this is my code:
processor p16f84a
include <p16f84a.inc>
__config _WDT_OFF & _PWRTE_OFF & _CP_OFF & _HS_OSC
cblock 0x0c
tmp
Reg_1
Reg_2
Reg_3
Reg_4
endc
bsf STATUS,5
clrf TRISB
bcf STATUS,5
clrf PORTB
main
call delay5ms
call LCD_init
movlw 0x01
call LCD_cmd
movlw 0x0e
call LCD_cmd
call delay1ms
movlw .65 ;put 'A'
call LCD_chr
movlw .109 ;put 'm'
call LCD_chr
movlw .105 ;put i
call LCD_chr
movlw .110 ;put n
call LCD_chr
movlw 0x00
call LCD_chr
movlw .65 ;put A
call LCD_chr
movlw .103 ;put g
call LCD_chr
movlw .104 ;put h
call LCD_chr
movlw .97 ;put a
call LCD_chr
movlw .107 ;put k
call LCD_chr
movlw .104 ;put h
call LCD_chr
movlw .97 ;put a
call LCD_chr
movlw .110 ;put n
call LCD_chr
movlw .105 ;put i
call LCD_chr
movlw 0x00
goto $-1
LCD_init
movlw 0x30
movwf 0x06
call LCD_clk
call delay1ms
call delay1ms
movlw 0x30
movwf 0x06
call LCD_clk
movlw 0x30
movwf 0x06
call LCD_clk
movlw 0x20
movwf 0x06
call LCD_clk
call delay1ms
call delay1ms
movlw 0x28
movwf 0x06
call LCD_clk
return
LCD_clk
bsf 0x06,0
call delay1ms
bcf 0x06,0
call delay1ms
return
LCD_cmd
movwf tmp
swapf tmp,0
andlw b'11110000'
call LCD_clk
movf tmp,0
andlw b'11110000'
movwf 0x06
call LCD_clk
retlw 0x00
LCD_chr
movwf tmp
swapf tmp,0
andlw b'11110000'
movwf 0x06
bsf 0x06,1
call LCD_clk
bcf 0x06,1
movf tmp,0
andlw b'11110000'
movwf 0x06
call delay1ms
bsf 0x06,1
call LCD_clk
bcf 0x06,1
retlw 0x00
delay1ms
movlw .151
movwf Reg_1
movlw .3
movwf Reg_2
decfsz Reg_1,F
goto $-1
decfsz Reg_2,F
goto $-3
nop
nop
return
delay5ms
movlw .251
movwf Reg_1
movlw .13
movwf Reg_2
decfsz Reg_1,F
goto $-1
decfsz Reg_2,F
goto $-3
nop
nop
return
end
I check it with other sources but....!
thanks
I have writen a code for use LCD in 4 bit mode!
It's wrong but I don't know what!please help!
this is my code:
processor p16f84a
include <p16f84a.inc>
__config _WDT_OFF & _PWRTE_OFF & _CP_OFF & _HS_OSC
cblock 0x0c
tmp
Reg_1
Reg_2
Reg_3
Reg_4
endc
bsf STATUS,5
clrf TRISB
bcf STATUS,5
clrf PORTB
main
call delay5ms
call LCD_init
movlw 0x01
call LCD_cmd
movlw 0x0e
call LCD_cmd
call delay1ms
movlw .65 ;put 'A'
call LCD_chr
movlw .109 ;put 'm'
call LCD_chr
movlw .105 ;put i
call LCD_chr
movlw .110 ;put n
call LCD_chr
movlw 0x00
call LCD_chr
movlw .65 ;put A
call LCD_chr
movlw .103 ;put g
call LCD_chr
movlw .104 ;put h
call LCD_chr
movlw .97 ;put a
call LCD_chr
movlw .107 ;put k
call LCD_chr
movlw .104 ;put h
call LCD_chr
movlw .97 ;put a
call LCD_chr
movlw .110 ;put n
call LCD_chr
movlw .105 ;put i
call LCD_chr
movlw 0x00
goto $-1
LCD_init
movlw 0x30
movwf 0x06
call LCD_clk
call delay1ms
call delay1ms
movlw 0x30
movwf 0x06
call LCD_clk
movlw 0x30
movwf 0x06
call LCD_clk
movlw 0x20
movwf 0x06
call LCD_clk
call delay1ms
call delay1ms
movlw 0x28
movwf 0x06
call LCD_clk
return
LCD_clk
bsf 0x06,0
call delay1ms
bcf 0x06,0
call delay1ms
return
LCD_cmd
movwf tmp
swapf tmp,0
andlw b'11110000'
call LCD_clk
movf tmp,0
andlw b'11110000'
movwf 0x06
call LCD_clk
retlw 0x00
LCD_chr
movwf tmp
swapf tmp,0
andlw b'11110000'
movwf 0x06
bsf 0x06,1
call LCD_clk
bcf 0x06,1
movf tmp,0
andlw b'11110000'
movwf 0x06
call delay1ms
bsf 0x06,1
call LCD_clk
bcf 0x06,1
retlw 0x00
delay1ms
movlw .151
movwf Reg_1
movlw .3
movwf Reg_2
decfsz Reg_1,F
goto $-1
decfsz Reg_2,F
goto $-3
nop
nop
return
delay5ms
movlw .251
movwf Reg_1
movlw .13
movwf Reg_2
decfsz Reg_1,F
goto $-1
decfsz Reg_2,F
goto $-3
nop
nop
return
end
I check it with other sources but....!
thanks