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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/05/04 02:14
Read: times


 
#67923 - RE: dont ban me! :)
Responding to: ???'s previous message
I am not surprised that you get only black boxes. Your code has no flow. It is just a compilation of sub-routines and unless you take care to tell the processor what to do, and when, you have no hope of getting it going. I have attempted to correct your code to get the proper flow and stop after displaying the message on LCD. ( THIS IS ASSUMING THAT THE TIMING ISSUES AND BIT SEQUENCES ARE OK . I HAVE NO IDEA ON YOUR HARDWARE AND ASSUME THE ROUTINES ORE OK )

Your PRINT routine had no provision for incrementing the DPTR and I have added it.

Your BEGIN is replaced with INITLCD. As to the LCD initialization, all that is required is FUNCTIONSET, DSIPLAYON and CLEAR in that order. Rest you can leave at default. Also some modules need the FUNCTIONSET called thrice with about 50ms, 15ms and 5ms time delay in between as far as I remember. Anyway now that RTC confusion is out, you can try out the LCD portion peacefully.


Hope that helps.

Raghu



=============================
; Code corrected by Raghu to display the LCDmessage
; alone for trials. Code unassembled and posted as is
;for check out by OP. Modifications identified by RR
;comment. 05 April 2004.

; Oct 26th 2002. Sean O'Donovan
; This 8051 assembler program writes the words
; DISPLAY_IS_O.K. to an LMO86ALN LCD display.

; but first it initialises the display as
; instructed in the HD44780 lcd DRIVER data sheet.

; Bit defenitions and Equates. RR

RS BIT P2.7
RW BIT P2.5
ENABLE BIT P2.6
READ_TIME BIT P2.2

CLEAR EQU 01H
FUNCTIONSET EQU 34H ;perhaps this should read 38h for 2 line display.
DISPLAYON EQU 0eH
ENTRYMODESET EQU 06H
BOTTOM EQU 0C0H
IT_IS_WORKING EQU 300H


ORG 0000H ; start the code at address 0H in the ROM.

JMP LCDINIT ; RR

ORG 20H

; NOW WE INITIALISE THE LCD
;USING THE HD44780 lcd DRIVER data sheet page 86.

;*****************************************************************************************
; THE LCD INITIALISATION ROUTINE SEE PAGE 86 OF HD44780 lcd DRIVER SPEC
LCDINIT : MOV P1,#0FFH ; RR
MOV R6,#30
CALL DELAY ; THE DELAY GIVES THE LCD TIME TO ACT.

MOV A ,#CLEAR ; SEE PAGE 89/90 OF HD44780 lcd DRIVER SPEC.
CALL INSTRUCTION_TO_LCD ;SEE TIMING DIAGRAM P67OF LM093.

MOV A ,#FUNCTIONSET ; SEE PAGE 89/90 OF HD44780 lcd DRIVER SPEC.
CALL INSTRUCTION_TO_LCD ;SEE TIMING DIAGRAM P67OF LM093.

MOV A ,#DISPLAYON ; SEE PAGE 89/90 OF HD44780 lcd DRIVER SPEC.
CALL INSTRUCTION_TO_LCD ;SEE TIMING DIAGRAM P67OF LM093.

MOV A ,#ENTRYMODESET ; SEE PAGE 89/90 OF HD44780 lcd DRIVER SPEC.
CALL INSTRUCTION_TO_LCD ;SEE TIMING DIAGRAM P67OF LM093.

MOV A ,#CLEAR ; SEE PAGE 89/90 OF HD44780 lcd DRIVER SPEC.
CALL INSTRUCTION_TO_LCD ;SEE TIMING DIAGRAM P67OF LM093.
; THIS IS THE END OF THE LCD INITIALISATION ROUTINE
;*****************************************************************************************
;NOW WE WRITE WORDS TO THE DISPLAY
REPEAT:
MOV R0,#0H
MOV R2,#0H
MOV DPTR, #IT_IS_WORKING ; MOV 300H TO DPTR
MOV A,#0H
CALL PRINTIT
MOV A,#BOTTOM ; MOVE CURSER TO BOTTOM ROW.
CALL INSTRUCTION_TO_LCD
JMP $ ; RR - remain here till reset

; **********************************************************************************
INSTRUCTION_TO_LCD:
; THIS ROUTINE SENDS MESSAGE DOWN TO THE LCD
; TELLING IT HOW TO BEHAVE.
CLR RS ; THE RS BIT LOW INDICATES AN INSTRUCTION WRITE. SEE TIMING DIAGRAM P67OF LM093.
CLR RW
MOV R6, #100
CALL DELAY
SETB ENABLE
MOV P1,A
CLR ENABLE
RET

;END INSTRUCTION_TO_LCD ROUTINE
; **********************************************************************************

PRINTIT:
; THIS ROUTINE PRINTS THE LETTERS POINTED BY THE DPTR.
; REFER TO THE WRITE TIMING DIAGRAM PAGE 67 OF LMO93 SPEC.
SETB RS ; THE RS BIT HIGH INDICATES A DATA WRITE.
CLR RW
SETB ENABLE
MOV R6,#30
CALL DELAY
MOVC A, @A+DPTR
CJNE A,#'!',PRINT ;HAVE WE REACHED THE LAS LETTER ?
CLR ENABLE
CLR RS
RET

;END PRINTIT ROUTINE
; **********************************************************************************

; A DELAY ROUTINE DEPENDING ON THE VALUE NOW IN R6
DELAY:
MOV R5, #0
LOOP:
DJNZ R5,LOOP
DJNZ R6,LOOP
RET ; RETURN TO WHERE CALLED FROM
;END DELAY ROUTINE


;**********************************************************************************
PRINT:
MOV P1,A ;SEND LETTER OUT TO PORT2 I.E. TO DISPLAY. SEE TIMING DIAGRAM P67 LM093 DATA WRITE.
CLR ENABLE
CLR RS
INC R2
MOV A,R2
INC DPTR ; RR
JMP PRINTIT

;END PRINT ROUTINE
; **********************************************************************************

; HERE WE STORE LETTERS IN ROM LOCATION 300H
ORG IT_IS_WORKING
DB 'ERIC MCNAMARA !' ; THIS STORES THESE LETTERS IN ROM 300H
; **********************************************************************************


; RR - Rest of the code down can safely be deleted if you only want to check the LCD display portion.

; THE ROUTINE THAT SENDS DATA FROM REAL TIME CLOCK TO THE LCD****************************
REAL_TIME_CLOCK:
;CLR P1.6 ; CHIP SELECT RTC
MOV R1,#07H ; place ram location 7 in R1
MOVX A,@R1 ; read into acc from outside Up from address stored in R1(7). This is the date
MOV 7AH,A ; STORE DAY (BOTH DIGITS) IN 7AH
MOV R3,#7AH ; put 7a into r3
MOV A,#0FH ; put f into accum
ANL A,@R1 ; and contents of A with contents at address(7) stored in R1
MOV 71H,A ;71H WILL STORE THE FIRST DIGIT
MOV R3,#7AH
MOV A,@R1
SWAP A
MOV R1,A
MOV A,#0FH
ANL A,R1
MOV 70H,A ;70H WILL STORE THE SECOND DAY DIGIT
RET

;START MAIN PROGRAM
LCALL REAL_TIME_CLOCK
LCALL SEND_RTC_TO_DISPLAY

JMP REPEAT ;KEEP ON REPEATING THE SENTENCE (DEMO CODE ONLY).
;END MAIN PROGRAM

SEND_RTC_TO_DISPLAY:
; THIS ROUTINE PRINTS THE LETTERS IN 70 AND 71.
; REFER TO THE WRITE TIMING DIAGRAM PAGE 67 OF LMO93 SPEC.
SETB RS ; THE RS BIT HIGH INDICATES A DATA WRITE.
CLR RW
SETB ENABLE
MOV R6,#30
CALL DELAY
MOV A, 70H
ADD A,#48 ; conv to ascii
MOV P1,A ;SEND LETTER OUT TO PORT2 I.E. TO DISPLAY. SEE TIMING DIAGRAM P67 LM093 DATA WRITE.
CLR ENABLE
CLR RS
CLR ENABLE
CLR RS
RET

END ; STOP COMPILING


List of 16 messages in thread
TopicAuthorDate
dont ban me! :)            01/01/70 00:00      
   RE: dont ban me! :)            01/01/70 00:00      
   RE: dont ban me! :)            01/01/70 00:00      
      RE: dont ban me! :)            01/01/70 00:00      
         RE: Raghu            01/01/70 00:00      
      RE: dont ban me! :)            01/01/70 00:00      
   RE: dont ban me! :)            01/01/70 00:00      
      RE: dont ban me! :)            01/01/70 00:00      
         RE: dont ban me! :)            01/01/70 00:00      
            RE: dont ban me! :)            01/01/70 00:00      
               RE: dont ban me! :)            01/01/70 00:00      
                  Application of mind- Steve            01/01/70 00:00      
                     RE: Application of mind- Steve            01/01/70 00:00      
                        RE: Application of mind- Steve            01/01/70 00:00      
                           RE: Application of mind- Steve            01/01/70 00:00      
                           RE: Application of mind- Eric            01/01/70 00:00      

Back to Subject List