Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/23/09 16:43
Read: times


 
#162717 - the remaining part of the program
Responding to: ???'s previous message
Here is the remaining part of the program:

;----------LCD Display----------
LCD_init:
MOV A,#38H ;init. LCD 2 lines, 5x7 matrix
ACALL COMMAND ;issue command
MOV A, #0EH ;LCD on, cursor on, blinks off
ACALL COMMAND ;issue command
MOV A, #01H ;clear LCD command
ACALL COMMAND ;issue command
MOV A, #06H ;shift cursor right
ACALL COMMAND ;issue command
MOV A, #80H ;cursor: line 1, pos. 1
ACALL COMMAND
RET

COMMAND:
ACALL READY ;is LCD ready?
MOV P0, A ;issue command code
CLR P2.0 ;RS=0 for command
CLR P2.1 ;R/W=0 to write to LCD
SETB P2.2 ;E=1 for H-to-L pulse
ACALL DELAY
CLR P2.2 ;E=0 , latch in
RET

DATA_DISPLAY:
ACALL READY ;is LCD ready?
MOV P0, A ;issue data
SETB P2.0 ;RS=1 for data
CLR P2.1 ;R/W=0 to write to LCD
SETB P2.2 ;E=1 for H-to-L pulse
ACALL DELAY ;give LCD some time
CLR P2.2 ;E=0, latch in
RET

READY: SETB P0.7 ;make P0.7 input port
CLR P2.0 ;RS=0 access command reg
SETB P2.1 ;R/W=1 read command reg
;read command reg and check busy flag
BACK4: CLR P2.2 ;E=0 for L-to-H pulse
ACALL DELAY ;give LCD some time
SETB P2.2 ;E=1 for L-to-H pulse
JB P0.7, BACK4 ;stay until busy flag=0
RET

DELAY: MOV R7, #50 ;50 or higher for fast CPUs
HERE2: MOV R6, #255 ;R4=255
HERE1: DJNZ R6, HERE1 ;stay until R4 becomes 0
DJNZ R7, HERE2
RET

;------------16-bit Hex to BCD conversion-----------
Hex2BCD:
MOV R3,#0
MOV R4,#0
MOV R5,#0
MOV R6,#0
MOV R7,#0

MOV B,#10
MOV A,R2
DIV AB
MOV R3,B
MOV B,#10
DIV AB
MOV R4,B
MOV R5,A
CJNE R1,#0H,HIGH_BYTE ;jump if R1 is not equal to 0H
RET
HIGH_BYTE:
MOV A,#6
ADD A,R3
MOV B,#10
DIV AB
MOV R3,B
ADD A,#5
ADD A,R4
MOV B,#10
DIV AB
MOV R4,B
ADD A,#2
ADD A,R5
MOV B,#10
DIV AB
MOV R5,B
CJNE R6,#0, ADD_IT ;jump if R6 is not equal to 0
SJMP CONTINUE
ADD_IT:
ADD A,R6
CONTINUE:
MOV R6,A
DJNZ R1,HIGH_BYTE
MOV B, #10
MOV A,R6
DIV AB
MOV R6,B
MOV R7,A
RET

;------------------------------------------------------------
END



Thanks for all you guys' concerns.

List of 14 messages in thread
TopicAuthorDate
edge-triggered interrupt            01/01/70 00:00      
   no throrough analysis, but            01/01/70 00:00      
      edge triggered interrupt            01/01/70 00:00      
         you need to read "the bible"            01/01/70 00:00      
            I did            01/01/70 00:00      
   edge triggered interrupt            01/01/70 00:00      
      already answered            01/01/70 00:00      
         edge triggered interrupt            01/01/70 00:00      
   Need better comments            01/01/70 00:00      
      Document "why" instead of "how"            01/01/70 00:00      
   Clear Interrupt flag before enabling interrupt            01/01/70 00:00      
      still imprecise            01/01/70 00:00      
   Some thoughts...            01/01/70 00:00      
      the remaining part of the program            01/01/70 00:00      

Back to Subject List