processor p16f84a
include <p16f84a.inc>
__config _XT_OSC & _CP_OFF & _PWRTE_OFF & _WDT_OFF
;*************************************************************************************************
;*********************************************8 bit LCD*******************************************
;*************************************************************************************************
;/////////////////////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////////////////////
;
; Amin Aghakhani
;
**broken link removed**
;
vishtaspahoraii@yahoo.com
;
;/////////////////////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////////////////////
;
; LCD port ----------> portb
; LCD_RS ----------> RA0
; LCD_E ----------> RA1
;
;/////////////////////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////////////////////
;*************************************************************************************************
;*********************************************8 bit LCD*******************************************
;*************************************************************************************************
cblock 0x0c
Reg_1
Reg_2
Reg_3
Reg_4
endc
tmp equ 0x10
clm equ 0x25
LCD_port equ 0x06
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Main codes%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bsf 0x03,5
clrf 0x86
clrf 0x85
bsf 0x85,2
movlw b'11111000'
movlw OPTION_REG
bcf 0x03,5
clrf 0x06
clrf 0x05
call delay50ms
call LCD_init
;Write Debounce on LCD
movlw .68
call LCD_CHR
movlw .101
call LCD_CHR
movlw .98
call LCD_CHR
movlw .111
call LCD_CHR
movlw .117
call LCD_CHR
movlw .110
call LCD_CHR
movlw .99
call LCD_CHR
movlw .101
call LCD_CHR
movlw .58
call LCD_CHR
;End of writing
count
btfsc 0x05,2
goto sss
goto $-2
sss
incf tmp,1
movlw 0xc0
addlw 0x09
call LCD_CMD
movf tmp,0
call LCD_CHR ;stooooooooop here! I wanna show number not character!plz help!
btfsc 0x05,2
goto $-1
goto count
;*******************************************************************************************************
;*******************************************************************************************************
;*******************************************************************************************************
LCD_init
movlw 0x30
call LCD_CMD
movlw 0x30
call LCD_CMD
movlw 0x30
call LCD_CMD
movlw 0x38
call LCD_CMD
movlw 0x0c
call LCD_CMD
movlw 0x01 ;clear display
call LCD_CMD
call delay1500us
return
LCD_CMD
movwf LCD_port
bsf 0x05,0
call delay800us
bcf 0x05,0
call delay800us
return
LCD_CHR
movwf LCD_port
bsf 0x05,1
bsf 0x05,0
call delay800us
bcf 0x05,0
bcf 0x05,1
call delay800us
retrun
;=================================================================================================
;=========================================Delay routines==========================================
;=================================================================================================
delay1500us
movlw .241
movwf Reg_1
movlw .2
movwf Reg_2
decfsz Reg_1,F
goto $-1
decfsz Reg_2,F
goto $-3
nop
nop
return
delay800us
movlw .8
movwf Reg_1
movlw .2
movwf Reg_2
decfsz Reg_1,F
goto $-1
decfsz Reg_2,F
goto $-3
nop
return
delay50ms
movlw .238
movwf Reg_1
movlw .65
movwf Reg_2
decfsz Reg_1,F
goto $-1
decfsz Reg_2,F
goto $-3
nop
return
end