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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/01/03 01:52
Read: times


 
#44577 - RE: anothe problem with HD44780U LCD
Responding to: ???'s previous message
thank you for your reply
the code is :

$MOD52 ; 8052 predefined symbols
BYTEVAL EQU P0 ; define processor - LCD bus connections
; define LCD control signal connections
RS EQU P3.5
RW EQU P3.6
EN EQU P3.7
ORG 0000h
LJMP MAIN
ORG 100h
MAIN:
MOV SP,#2FH ; set start of stack at 30h
LCALL INIT_LCD
; define 8 bit interface,2line BYTEVALlay, 5x7 font
LCALL CLR_LCD ; clear screen
; define data string and transfer (for each character)
MOV A,#'h'
LCALL WRITE_DATA_TO_LCD ; transfer data
MOV A,#'i'
LCALL MOVE_LCD_L2 ; move to start of line 2
MOV A,#'u'
LCALL WRITE_DATA_TO_LCD
MAINloop:
nop ; loop main program sjmp MAINloop
ORG 800h
CHK_LCD_BUSY: ; loop until busy flag deasserted, RS defaults to 0 elsewhere as required
;for BUSY flag read
MOV BYTEVAL,#0FFh ; set all LCD port pins as inputs
SETB EN ; EN must be asserted before busy flag is read
SETB RW ; reading port
MOV A,BYTEVAL ; read BYTEVAL from LCD
JB ACC.7,CHK_LCD_BUSY ; test busy flag and wait until clear (if set, loop since LCD is
;busy)
CLR RW ; return to default value
RET
WRITE_CONTROL_TO_LCD: ; transfer control byte to LCD, RS defaults to 0 (control
;transfer)
MOV BYTEVAL,A ; define bus values. Control signal defaults defined
;elsewhere : EN=1, RS=0, RW=0
CLR EN ; transfer.
LCALL CHK_LCD_BUSY
RET
WRITE_DATA_TO_LCD: ; transfer data byte to LCD
SETB RS ; set RS (data transfer) since it defaults to 0 (control transfer)
MOV BYTEVAL,A ; define bus values. Control signal defaults defined elsewhere :
;EN=1, RS=0, RW=0
CLR EN ; transfer.
CLR RS ; RS default
LCALL CHK_LCD_BUSY
RET
INIT_LCD: ; 8bit interface, 2 line BYTEVALlay, 5x7 font
CLR RS ; RS default 0 => control byte transfer
CLR RW ; RW default 0 => writing
SETB EN ; EN default 1
MOV A,#38h ; set bus width (8 bits) and display type (2 line, 5x7 dot font)
LCALL WRITE_CONTROL_TO_LCD
MOV A,#0Eh ; turn on display and blinking cursor
LCALL WRITE_CONTROL_TO_LCD
MOV A,#06h ; automatically move cursor to right on character write
LCALL WRITE_CONTROL_TO_LCD
RET
CLR_LCD: ;clr screen, cursor on up left corner; useful as a separate routine
MOV A,#01h ; clear LCD display, place cursor on left of display
LCALL WRITE_CONTROL_TO_LCD
RET
MOVE_LCD_L1: ; cursor on left position of line 1; useful as a separate routine
MOV A,#80h ; Set DDRAM Address : DB7=1, DB6:DB0=00h (first line, left hand side
LCALL WRITE_CONTROL_TO_LCD
RET
MOVE_LCD_L2: ; cursor on left position of line 2; useful as a separate routine
MOV A,#0C0h ; Set DDRAM Address : DB7=1, DB6:DB0=40h (second line, left hand side
LCALL WRITE_CONTROL_TO_LCD
RET
END

List of 15 messages in thread
TopicAuthorDate
anothe problem with HD44780U LCD            01/01/70 00:00      
   RE: anothe problem with HD44780U LCD            01/01/70 00:00      
      RE: anothe problem with HD44780U LCD            01/01/70 00:00      
   RE: anothe problem with HD44780U LCD            01/01/70 00:00      
      RE: anothe problem with HD44780U LCD            01/01/70 00:00      
         RE: anothe problem with HD44780U LCD            01/01/70 00:00      
            RE: anothe problem with HD44780U LCD            01/01/70 00:00      
               RE: anothe problem with HD44780U LCD            01/01/70 00:00      
            RE: anothe problem with HD44780U LCD            01/01/70 00:00      
               RE: anothe problem with HD44780U LCD            01/01/70 00:00      
                  RE: anothe problem with HD44780U LCD            01/01/70 00:00      
                     RE: anothe problem with HD44780U LCD            01/01/70 00:00      
                        RE: Michael Karas            01/01/70 00:00      
               RE: rami            01/01/70 00:00      
            RE: anothe problem with HD44780U LCD            01/01/70 00:00      

Back to Subject List