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

Back to Subject List

Thread Closed: Issue successfully resolved

???
02/05/04 12:14
Read: times


 
#64052 - RE: 8051 with LCD
Responding to: ???'s previous message
Hey steve I tried looking at the tutorial. This is what I came up with

$MOD812S
DB0 EQU P0.0
DB1 EQU P0.1
DB2 EQU P0.2
DB3 EQU P0.3
DB4 EQU P0.4
DB5 EQU P0.5
DB6 EQU P0.6
DB7 EQU P0.7
EN EQU P3.5
RS EQU P3.1
RW EQU P3.3
ODATA EQU P0

CSEG ; Defines the following as a
; segment of code
ORG 0000H ; Load Code at '0' ; (main program)
START: LCALL MAIN


;======================================================================
; INITIALLCD ROUTINE INITIALIZES THE LCD DISPLAY AS A
; 16 CHARACTER 2-LINE DISPLAY WITH 5*7 FONT
;======================================================================
INIT_LCD:

SETB EN
CLR RS
MOV ODATA,#38h
CLR EN
LCALL WAIT_LCD
SETB EN
CLR RS
MOV ODATA,#0Eh
CLR EN
LCALL WAIT_LCD
SETB EN
CLR RS
MOV ODATA,#06h
CLR EN
LCALL WAIT_LCD
RET
;======================================================================
; THIS ROUTINE CLEARS THE LCD DISPLAY AND PREPARES IT FOR DISPLAYING
; CHARACTERS
;======================================================================
CLEAR_LCD:

SETB EN
CLR RS
MOV ODATA,#01h
CLR EN
LCALL WAIT_LCD
RET
;======================================================================
; THIS LOOP CHECKS TO SEE IF THE BUSY FLAG IS SET IF IT IS THEN NOTHING
; CAN BE READ OR WRITTEN
;======================================================================
WAIT_LCD:

SETB EN ;Start LCD command
CLR RS ;It's a command
SETB RW ;It's a read command
MOV ODATA,#0FFh ;Set all pins to FF initially
MOV A,ODATA ;Read the return value
JB ACC.7,WAIT_LCD ;If bit 7 high, LCD still busy
CLR EN ;Finish the command
CLR RW ;Turn off RW for future commands
RET


;======================================================================
; THIS ROUTINE WRITES THE ASCII VALUE IN A ON TO THE LCD DISPLAY AND
; THEN CHECKS THE BUSY FLAG
;======================================================================
WRITE_TEXT:

SETB EN
SETB RS
MOV ODATA,A
CLR EN
LCALL WAIT_LCD
RET

MAIN:
LCALL INIT_LCD
LCALL CLEAR_LCD
MOV A,#'H'
LCALL WRITE_TEXT
MOV A,#'E'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
SETB EN
CLR RS
MOV ODATA,#0C4h
CLR EN
LCALL WAIT_LCD
MOV A,#'W'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'R'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'D'
LCALL WRITE_TEXT

END


But I have a problem with the WAIT_LCD PROC. It sets all bits of ODATA to 1s (FFh) but it then checks if bit 7 of ODATA is low otherwise it loops back to WAIT_LCD. If this is the case will this not be an endless loop as bit 7 will always be high in this procedure or am I interpreting the code wrong.

Thanks again for your help.


List of 32 messages in thread
TopicAuthorDate
8051 with LCD            01/01/70 00:00      
   RE: 8051 with LCD            01/01/70 00:00      
      RE: 8051 with LCD            01/01/70 00:00      
      RE: 8051 with LCD            01/01/70 00:00      
      RE: 8051 with LCD            01/01/70 00:00      
         RE: 8051 with LCD            01/01/70 00:00      
   RE: 8051 with LCD            01/01/70 00:00      
   RE: 8051 with LCD            01/01/70 00:00      
      RE: 8051 with LCD            01/01/70 00:00      
   RE: 8051 with LCD            01/01/70 00:00      
   8051 with 20x2 LCD            01/01/70 00:00      
      RE: 8051 with 20x2 LCD            01/01/70 00:00      
      RE: 8051 with 20x2 LCD            01/01/70 00:00      
         RE: 8051 with 20x2 LCD            01/01/70 00:00      
            RE: 8051 with 20x2 LCD            01/01/70 00:00      
               RE: 8051 with 20x2 LCD            01/01/70 00:00      
                  RE: 8051 with 20x2 LCD            01/01/70 00:00      
                     RTFM            01/01/70 00:00      
                        Could not agree more!            01/01/70 00:00      
                        RE: RTFM            01/01/70 00:00      
                        RE: RTFM            01/01/70 00:00      
                     RE: 8051 with 20x2 LCD - Russell            01/01/70 00:00      
                        RE: 8051 with 20x2 LCD - Russell            01/01/70 00:00      
                           RE: 8051 with 20x2 LCD - Russell            01/01/70 00:00      
                              RE: 8051 with 20x2 LCD - Oleg            01/01/70 00:00      
      RE: 8051 with 20x2 LCD - Kapil            01/01/70 00:00      
         RE: 8051 with 20x2 LCD - Kapil            01/01/70 00:00      
            RE: 8051 with 20x2 LCD - Kapil            01/01/70 00:00      
               RE: 8051 with 20x2 LCD            01/01/70 00:00      
                  RE: 8051 with 20x2 LCD            01/01/70 00:00      
            RE: 20x2 LCD = 16x2 LCD !            01/01/70 00:00      
               RE: 20x2 LCD = 16x2 LCD !            01/01/70 00:00      

Back to Subject List