pratzz
Member level 5
- Joined
- Jun 15, 2012
- Messages
- 83
- Helped
- 6
- Reputation
- 12
- Reaction score
- 6
- Trophy points
- 1,288
- Activity points
- 1,781
Code:
list p=PIC16F877a
#include <p16F877a.inc>
errorlevel -302
__config _HS_OSC & _LVP_OFF
en equ 4
rw equ 5
rs equ 6
;-------------------------------------------
; GENERAL PURPOSE REGISTERS
;-------------------------------------------
CBLOCK 20h
temp1
temp2
temp
temp3
temp4
num
count
ENDC
ORG 0
clrf STATUS
movlw 00
movwf PCLATH
goto start
;------------------------------------------
org 04
retfie
table1
movlw HIGH $
movwf PCLATH
movf temp3,w
addwf PCL,f
dt " EXCEL ",0
table2
movlw HIGH $
movwf PCLATH
movf temp4,w
addwf PCL,f
dt "UNIVERSALTRAINER",0
delay
movwf temp2
movlw (0ff-0feh)
movwf temp1
clrwdt
incfsz temp1,1
goto $-2
decfsz temp2,1
goto $-6
retlw 0
lcd_init
movlw 0fh
movwf PORTB
bsf PORTB,en
BSF PORTB,rs
movlw .15
call delay
movlw 03h
movwf PORTB
bsf PORTB,en
nop
bcf PORTB,en
movlw .15
call delay
movlw 03h
movwf PORTB
bsf PORTB,en
nop
bcf PORTB,en
movlw .15
call delay
movlw 02h
movwf PORTB
bsf PORTB,en
nop
bcf PORTB,en
movlw .15
call delay
movlw 28H ;4-bit, 2 line, 5x7 dots
call lcd_cmd ;Call LCD command
movlw 15h
call delay
movlw 0CH ;Display ON cursor OFF
call lcd_cmd ;Call LCD command
movlw 15h
call delay
movlw 06H ;Set entry mode (Auto increment)
call lcd_cmd ;Call LCD command
movlw 15h
call delay
movlw 80H ;Bring cursor to line 1
call lcd_cmd ;Call LCD command
retlw 00h
;-------------------------------------------------------------------
lcd_cmd
movwf temp
swapf temp,W
andlw 0fh
movwf PORTB
bcf PORTB,rs
bcf PORTB,rw
bsf PORTB,en
;movlw .15
;call delay
bcf PORTB,en
movf temp,W
andlw 0fh
movwf PORTB
bcf PORTB,rs
bcf PORTB,rw
bsf PORTB,en
movlw .15
call delay
bcf PORTB,en
retlw 00h
lcd_data
movwf temp
swapf temp,W
andlw 0fh
iorlw 40h
movwf PORTB
bsf PORTB,rs
bcf PORTB,rw
bsf PORTB,en
; movlw .15
; call delay
bcf PORTB,en
movf temp,W
andlw 0fh
movwf PORTB
bsf PORTB,rs
bcf PORTB,rw
bsf PORTB,en
movlw .15
call delay
bcf PORTB,en
retlw 00h
initialise
clrf temp3
clrf temp4
clrf num
bcf STATUS,RP1
bsf STATUS,RP0
clrf TRISB
movlw b'00000111'
movwf ADCON1
bcf STATUS,RP0
retlw 00
;--------------------------------------------------------------
start
call initialise
call lcd_init
y call table1
iorlw 00h
btfsc STATUS,Z
goto z
call lcd_data
incf temp3,1
;decfsz count,1
goto y
;movlw d'16'
;movwf count
z movlw 0c0h
call lcd_cmd
z1 call table2
iorlw 00h
btfsc STATUS,Z
goto x
call lcd_data
incf temp4,1
;decfsz count,1
goto z1
x goto x
end
while the display is running fine on simulation,hardware implementation show absurd characters.