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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/02/03 16:47
Read: times


 
#44698 - Display symbol to LCD
According to the last program below, I can display what I want, but I want to display "+", "-", "x", "/"...

The normal way is that
---------------------------
ORG 800h
ACALL LCD_INIZALIZE

MOV DPTR, #MATH_5
ACALL LCD_MSG
MOV A, #45
ACALL Cursor_Pos

MATH_5: DB '+', 00h

END
-------------------------------
But since this method will use a lot of places or more than 4K and I can't add external RAM don't ask me why, what can I do if I want to reduces the bytes in the program? i have read that can save ASCII to A and use DDRAM to display it.. but I really don't understand it!

Please Help or give me some suggestions.

Thank you!


;
;Here is an LCD display driver package that supports the 4x20 LCD character
;module that use the standard Hitachi HD44780/HD44100 LCD controller or
;compatible.
;

;**************************************
; Constant Definition
;**************************************
;

LCD_RS EQU P1.4 ;Define LCD RS pin = P1.4
LCD_RW EQU P1.5 ;Define LCD R/W pin = P1.5
LCD_E EQU P1.6 ;Define LCD Enable pin = P1.6
LCD_DATA EQU P0 ;Define LCD Data bus = P0


;***************************************
; Subroutine: LCD_BUSY
;
;The LCD controller chip needs some time to execute the instruction or data
;write, and whenever it receives something it starts this internal operation
;routine takes time, during this time the controller will be busy and will not
;understand anything else that we send. So it will be necessary to wait a
;little bit after we send something to the LCD. How long is it? Nobody
;knows, it depends on the controller type and operation, and it can varies.
;We can build a "wasting time" routine to wait for some time after each write
;to the LCD, but it might be too short or too long because we would never know
;how long will be enough. To avoid guessing and testing, just use a simply
;way to check if the LCD controller is busy or not, there is the busy bit.
;After writing to the LCD, send a "read instruction" and check bit 7, this is
;the busy bit, a high level means the controller still busy, a low level means
;the controller finished the previous operation and is available to receive
;more bytes.
;***************************************

LCD_BUSY:
CLR LCD_E ;Make sure LCD is not selected
SETB P0.7 ;Make sure bit 7 will be pull up to read OK
SETB LCD_RW ;Sets the display bus for a read operation
CLR LCD_RS ;Instruction operation
LB1: CLR LCD_E ;Deselect LCD
SETB LCD_E ;Select LCD for read
JB P0.7,LB1 ;Still busy? Keep checking
CLR LCD_E ;Not busy anymore, deselect LCD
RET ;Return to Caller


;**************************************
; Subroutine: DataWrite
;
;To write a character (Data) into the LCD display, it is necessary to preset
;LCD_RS High, LCD_RW low, character byte at Data pins 7-14, and then pulse
;LCD_E pin up once. Character is passing to the subroutine via the Acc.
;**************************************
DataWrite:
MOV LCD_DATA,A ;Post Acc at LCD data input
SETB LCD_RS ;Set RS high (Data)
CLR LCD_RW ;Set RW low (Write)
NOP ;Wait circuit settling
SETB LCD_E ;Tells the LCD to work (receive data byte)
NOP ;Wait a little bit
NOP ;
ACALL LCD_BUSY ;Wait controller not busy
RET ;Return to Caller


;**************************************
; Subroutine: CmdWrite
;
;To write a command or address (Instruction) to the LCD, preset LCD_RS Low,
;LCD_RW low, command or address at Data pins 7-14, and then pulse LCD_E pin
;up once. The instruction is passing to the subroutine via the Acc.
;***************************************

CmdWrite:
MOV LCD_DATA,A ;Post accumulator at LCD data input
CLR LCD_RS ;Set RS low (Instruction)
CLR LCD_RW ;Set RW low (Write)
NOP ;Wait circuit settling
SETB LCD_E ;Tells the LCD to work (receive instruction
;byte)
NOP ;Wait a little bit
NOP ;
CLR LCD_E ;Drop the selection line
RET ;Return to Caller


;**************************************
; Subroutine: InstructionWrite
;
;This routine is basically the same as CmdWrite with the ONLY exception that
;busy bit is being checked instead of using "wasting time" routine.
;***************************************

InstructionWrite:
MOV LCD_DATA,A ;Post accumulator at LCD data input
CLR LCD_RS ;Set RS low (Instruction)
CLR LCD_RW ;Set RW low (Write)
NOP ;Wait circuit settling
SETB LCD_E ;Tells the LCD to work (receive instruction
;byte)
NOP ;Wait a little bit
NOP ;
ACALL LCD_BUSY ;Wait controller not busy
RET ;Return to Caller


;**************************************
; Subroutine: LCD_Initialize
;
;At power on, the LCD needs to be programmed for proper operation. It
;consists to send a series of command bytes to the LCD. For our tests here,
;the sequence is 38h, 38h, 38h, 06h, 0Eh, 01h. This will program the LCD for
;display active, new characters to the right, character normal size 5x7 dots,
;increment cursor position, cursor on, not blinking. To do that, we just need
;to post those bytes one by one at port P0 (according to the schematic), and
;execute the instruction CmdWrite as described above, for each byte in the
;sequence. The ACALL Delay10ms instructions are necessary because the LCD
;needs some time to execute the first command sent, and the busy bit is NOT
;working yet.
;**************************************

LCD_Initialize:
MOV A,#038h ;Data length (8 bits), 2 lines, char 5x7
ACALL CmdWrite ;Needs 3 times this byte (1st)
ACALL Delay10ms ;Some delay routine 10 milliseconds
;
ACALL CmdWrite ;(second)
ACALL Delay10ms ;Some delay routine 10 milliseconds
;
ACALL CmdWrite ;(third)
ACALL Delay10ms ;Some delay routine 10 milliseconds
;
MOV A,#06h ;Move direction and Shift Display
ACALL CmdWrite ;
ACALL Delay10ms ;Some delay routine 10 milliseconds
;
MOV A,#0Eh ;Display and Cursor ON, not blinking
ACALL CmdWrite

MOV A,#01h ;LCD Clear
ACALL CmdWrite
RET ;and return to Caller


;***************************************
; Subroutine: LCD_MSG
;
;This routine is used to display text string at the current cursor position.
;To call this routine, first load DPTR with the text string address. Each
;text string is ended with a "zero" to indicate the end of string.
;***************************************

LCD_MSG:
CLR A ;Clear index
MOVC A,@A+DPTR ;Get byte pointed by DPTR
INC DPTR ;Point to next byte
JZ END_OF_MSG ;Return if found the zero (end of string)
ACALL DataWrite ;It was data, write it to LCD
SJMP LCD_MSG ;Go get next byte from string
END_OF_MSG: ;Return to Caller
RET


;***************************************
;Subroutine: Cursor_Pos
;
;This routine is used to set the cursor position at the specified DD RAM
;address. The address position is passed to the routine via the Acc.
;***************************************

Cursor_Pos:
ORL A,#10000000b
ACALL InstructionWrite
RET


;***************************************
;Subroutine: Clear_Screen
;
;This routine is used to clear the LCD screen and home the cursor position at
;the left hand upper corner.
;***************************************

Clear_Screen:
MOV A,#00000001b
ACALL InstructionWrite
RET


;***************************************
; Subroutine: Delay10ms
;
;This delay routine will delay for approx. 10 ms (Assume 11.0592 MHz crystal)

Delay10ms:
PUSH 02
PUSH 01
MOV R2,#24
DLY1: MOV R1,#200
DJNZ R1,$
DJNZ R2,DLY1
POP 01
POP 02
RET




List of 7 messages in thread
TopicAuthorDate
Display symbol to LCD            01/01/70 00:00      
   RE: Display symbol to LCD            01/01/70 00:00      
      RE: Display symbol to LCD            01/01/70 00:00      
         RE: Display symbol to LCD            01/01/70 00:00      
   RE: Display symbol to LCD            01/01/70 00:00      
      RE: Display symbol to LCD - Rob            01/01/70 00:00      
      RE: Display symbol to LCD            01/01/70 00:00      

Back to Subject List