hi thank you every1. here i have added some lcd program which i have learn from a book. lcd accept 4 bit data at a time.
this part is only for lcd to display character and turn lcd on. what i need to do, is to add more program to generate random number between 0 to 27 and display it on screen.
plz help
i'm doing my best to get it working.
thank u very much for you replies.
;ANHEAD877.ASM Header for the alpha numeric display csing 6 I/0
TMR0 EQU 1 ;means TMR0 is file 1.
STATUS EQU 3 ;means STATUS is file 3.
PORTA EQU 5 ;means PORTA is file 5.
PORTB EQU 6 ;means PORTB is file 6.
PORTC EQU 7 ;means PORTB is file 7.
PORTD EQU 8 ;means PORTB is file 8.
TRISA EQU 85H ;TRISA (the PORTA I/O selection) is file 85H
TRISB EQU 86H ;TRISB (the PORTB I/O selection) is file 86H
TRISC EQU 87H ;TRISC (the PORTC I/O selection) is file 87H
TRISD EQU 88H ;TRISD (the PORTD I/O selection) is file 88H
OPTION EQU 81H ;the OPTION register is file 81H
ZEROBIT EQU 2 ;means ZEROBIT is bit 2.
COUNT EQU 0CH ;COUNT is file 0C, a register to count events.
;****************************************************************************
LIST P=16F877 ;we are using the 16F877.
ORG 0 ;the start address in memory is 0
GOTO START ;goto start!
;****************************************************************************
; Configuration Bits
_CONFIG H'3FF0' ;selects LP oscillator, WDT off, PUT on,
;Code Protection disabled.
;****************************************************************************
; SUBROUTINE SECTION.
;3 SECOND DELAY
DELAY3 CLRF TMR0 ;Start TMR0
LOOPA MOVF TMR0.W ;Read TMR0 into W
SUBLW .96 ;TIME - W
BTFSS STATUS,ZEROBIT ;Check TIME-W = 0
GOTO LOOPA
RETLW 0 ;return after TMRO = 96
;P1 SECOND DELAY
DELAP1 CLRF TMR0 ;Start TMR0
LOOPC MOVF TMR0.W ;Read TMR0 into W
SUBLW .3 ;TIME - W
BTFSS STATUS,ZEROBIT ;Check TIME-W = 0
GOTO LOOPC
RETLW 0 ;return after TMRO = 3
CLOCK BSF PORTA,2
NOP
BCF PORTA,2
NOP
RETLW 0
;***************************************************************************
A MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 1H
MOVWF PORTB
CALL CLOCK
RETLW 0
BB MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 2H
MOVWF PORTB
CALL CLOCK
RETLW 0
C MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 3H
MOVWF PORTB
CALL CLOCK
RETLW 0
D MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 4H
MOVWF PORTB
CALL CLOCK
RETLW 0
E MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 5H
MOVWF PORTB
CALL CLOCK
RETLW 0
F MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 6H
MOVWF PORTB
CALL CLOCK
RETLW 0
G MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 7H
MOVWF PORTB
CALL CLOCK
RETLW 0
H MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 8H
MOVWF PORTB
CALL CLOCK
RETLW 0
I MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 9H
MOVWF PORTB
CALL CLOCK
RETLW 0
J MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 0AH
MOVWF PORTB
CALL CLOCK
RETLW 0
K MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 0BH
MOVWF PORTB
CALL CLOCK
RETLW 0
L MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 0CH
MOVWF PORTB
CALL CLOCK
RETLW 0
M MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 0DH
MOVWF PORTB
CALL CLOCK
RETLW 0
N MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 0EH
MOVWF PORTB
CALL CLOCK
RETLW 0
O MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 0FH
MOVWF PORTB
CALL CLOCK
RETLW 0
P MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVWF 0H
MOVWF PORTB
CALL CLOCK
RETLW 0
Q MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVWF 1H
MOVWF PORTB
CALL CLOCK
RETLW 0
R MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVWF 2H
MOVWF PORTB
CALL CLOCK
RETLW 0
S MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVWF 3H
MOVWF PORTB
CALL CLOCK
RETLW 0
T MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVWF 4H
MOVWF PORTB
CALL CLOCK
RETLW 0
U MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVWF 5H
MOVWF PORTB
CALL CLOCK
RETLW 0
V MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVWF 6H
MOVWF PORTB
CALL CLOCK
RETLW 0
WW MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVWF 7H
MOVWF PORTB
CALL CLOCK
RETLW 0
X MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVWF 8H
MOVWF PORTB
CALL CLOCK
RETLW 0
Y MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVWF 9H
MOVWF PORTB
CALL CLOCK
RETLW 0
Z MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVWF 0AH
MOVWF PORTB
CALL CLOCK
RETLW 0
NUM0 MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVWF 0H
MOVWF PORTB
CALL CLOCK
RETLW 0
NUM1 MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVWF 1H
MOVWF PORTB
CALL CLOCK
RETLW 0
NUM2 MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVWF 2H
MOVWF PORTB
CALL CLOCK
RETLW 0
NUM3 MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVWF 3H
MOVWF PORTB
CALL CLOCK
RETLW 0
NUM4 MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVWF 4H
MOVWF PORTB
CALL CLOCK
RETLW 0
NUM5 MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVWF 5H
MOVWF PORTB
CALL CLOCK
RETLW 0
NUM6 MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVWF 6H
MOVWF PORTB
CALL CLOCK
RETLW 0
NUM7 MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVWF 7H
MOVWF PORTB
CALL CLOCK
RETLW 0
NUM8 MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVWF 8H
MOVWF PORTB
CALL CLOCK
RETLW 0
NUM9 MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVWF 9H
MOVWF PORTB
CALL CLOCK
RETLW
GAP MOVLW 2
MOVWF PORTA
MOVLW 2H
MOVWF PORTB
CALL CLOCK
MOVWF 0H
MOVWF PORTB
CALL CLOCK
RETLW 0
DOT MOVLW 2
MOVWF PORTA
MOVLW 2H
MOVWF PORTB
CALL CLOCK
MOVWF 0EH
MOVWF PORTB
CALL CLOCK
RETLW 0
CLRDISP MOVWF PORTA
MOVLW 0H
MOVWF PORTB
CALL CLOCK
MOVWF 1
MOVWF PORTB
CALL CLOCK
CALL DELAYP1
RETLW 0
;******************************************************************************
;CONFIGURATION SECTION.
START BSF STATUS,5 ;Turns to Bank1.
MOVLW B'00000000' ;PORTA is O/P
MOVWF TRISA
MOVLW B'00000000' ;PORTA is O/P
MOVWF TRISB
;Display CONFIGURATION
MOVLW 02H
MOVWF PORTB
CALL CLOCK
CALL DELAYP1
MOVLW 02H
MOVWF PORTB
CALL CLOCK
CALL DELAYP1
MOVLW 08H
MOVWF PORTB
CALL CLOCK
CALL DELAYP1
MOVLW 0H
MOVWF PORTB
CALL CLOCK
MOVLW 0cH
MOVWF PORTB
CALL CLOCK
CALL DELAYP1
MOVLW 0H
MOVWF PORTB
CALL CLOCK
MOVLW 6H
MOVWF PORTB
CALL CLOCK
***********************************************************************
;program stats now.
Begin CALL CLRDISP
CLRF PORTA
MOVLW 8H
MOVWF PORTB
CALL CLOCK
MOVLW 0H
MOVWF PORTB
CALL CLOCK
CALL M
CALL DELAYP1
CALL I
CALL DELAYP1
CALL C
CALL DELAYP1
CALL R
CALL DELAYP1
CALL O
CALL DELAYP1
CALL C
CALL DELAYP1
CALL O
CALL DELAYP1
CALL N
CALL DELAYP1
CALL T
CALL DELAYP1
CALL R
CALL DELAYP1
CALL O
CALL DELAYP1
CALL L
CALL DELAYP1
CALL L
CALL DELAYP1
CALL E
CALL DELAYP1
CALL R
CALL DELAYP1
CALL S
CALL DELAYP1
CLRF PORTA
MOVLW 0CH ; CURSOR ON SECOND LINE, C3
MOVWF PORTB
CALL CLOCK
MOVLW 3H
MOVWF PORTB
CALL CLOCK
CALL A
CALL DELAYP1
CALL T
CALL DELAYP1
CALL GAP
CALL L
CALL DELAYP1
CALL O
CALL DELAYP1
CALL N
CALL DELAYP1
CALL D
CALL DELAYP1
CALL O
CALL DELAYP1
CALL N
CALL DELAYP3
GOTO BEGIN
END
hum