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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/31/07 11:52
Read: times


 
#131780 - TESTED code for LCD
Responding to: ???'s previous message
i have made this code have tested
you copy past in simulator
simulate the code
create hex file
send it to controller

IF then its not working then it is sure hardware prob or simulating prob

some times lcd does not get initialised because of the delay is not proper and i have used busy flag so dont wory about delays
and pin configuration you can modify




;*********************************************************************
;THIS CODE WILL DISPAY A CHARACTER "G" ON LCD AND SINK THE CHAR DOWNWARDS
;*********************************************************************


.org 0000h
;*********************************************************************
;PORT DEFINED (CAN BE MODIFIED ACCORING TO CIRCUIT
;*********************************************************************
;p0= d0-d7
;RS rs=0 for command rs=1 for data
;RW wr=0 for write wr=1 for read
;EN enable -\_
.equ RS, p3.5
.equ RW, p3.4
.equ EN, p3.3
;*********************************************************************
;TO INITIALIZE THE LCD
;*********************************************************************

mov a,#38h ;2 line 5x7
acall command
mov a,#0ch ;lcd on cursor on
acall command
mov a,#01h ;clr lcd
acall command
mov a,#06h ;shift cursor right
acall command

mov a,#'a' ; testing for "a"
acall ddisp

acall delay
acall writech ;writes char in CG ram of lcd

mov a,#80h ;go to start of lcd
acall command
mov a,#01h
acall command ;clr disp

;*********************************************************************
;LOOP FOR DISPLAYING 8 ROW (1CHAR) STORED IN CG RAM
;*********************************************************************

s:
mov r0,#00h ;CGram address
again1: mov a,#85h ;DDRAM addres display position on lcd
acall command
acall delay
mov a,r0 ; r0=0 means first char of cg ram
acall ddisp ; display on lcd
inc r0 ; inc counter
cjne r0,#08h,again1

sjmp s ; main loop reapet


command:acall ready ;chk lcd is ready to accept command
mov p0,a
clr RS ;rs=0 for command
clr RW ;wr=0 for write
setb EN
clr EN
ret

ddisp: acall ready
mov p0,a
setb RS ;rs=1 for data
clr RW ;wr=0 for write
setb EN
clr EN
ret

ready: setb p0.7
clr RS ;rs=0 command
setb RW ;wr=1 read
back: clr EN ;enable
setb EN
jb p0.7,back
ret

delay: mov r7,#99h
w2: mov r6,#00h
w1: djnz r6,w1
djnz r7,w2
ret

writech:acall ready
mov a,#40h ; go to 00 of cgram
mov p0,a
clr RW
clr RS
setb EN
clr EN


mov r7,#64 ;counter for 64 times 8pix hor x 8lines = 1 char
mov dptr,#tabel ;load address values of tabel
wr1: clr a
acall ready
movc a,@a+dptr
mov p0,a ; this will write tabel in cgram (address 40 of lcd
setb RS
clr RW
setb EN
clr EN
inc dptr
djnz r7,wr1
ret
;*********************************************************************
;TABEL FOR 8 CHAR
;MADE SUCH THAT CHAR "G" IS SINKING DOWN
;*********************************************************************

tabel:
.db 00001110b ;char 1 of CGRAM
.db 00010001b ;1=high pixel
.db 00010000b ;0=low pix
.db 00010000b
.db 00010011b
.db 00010001b
.db 00010001b
.db 00001110b

.db 00000000b
.db 00001110b ;char 2 of CGRAM
.db 00010001b ;1=high pixel
.db 00010000b ;0=low pix
.db 00010000b
.db 00010011b
.db 00010001b
.db 00010001b

.db 00000000b
.db 00000000b
.db 00001110b ;char 3 of CGRAM
.db 00010001b ;1=high pixel
.db 00010000b ;0=low pix
.db 00010000b
.db 00010011b
.db 00010001b


.db 00000000b
.db 00000000b
.db 00000000b
.db 00001110b ;char 4 of CGRAM
.db 00010001b ;1=high pixel
.db 00010000b ;0=low pix
.db 00010000b
.db 00010011b

.db 00000000b
.db 00000000b
.db 00000000b
.db 00000000b
.db 00001110b ;char 5 of CGRAM
.db 00010001b ;1=high pixel
.db 00010000b ;0=low pix
.db 00010000b

.db 00000000b
.db 00000000b
.db 00000000b
.db 00000000b
.db 00000000b
.db 00001110b ;char 6 of CGRAM
.db 00010001b ;1=high pixel
.db 00010000b ;0=low pix

.db 00000000b
.db 00000000b
.db 00000000b
.db 00000000b
.db 00000000b
.db 00000000b
.db 00001110b ;char 7 of CGRAM
.db 00010001b ;1=high pixel

.db 00000000b
.db 00000000b
.db 00000000b
.db 00000000b
.db 00000000b
.db 00000000b
.db 00000000b
.db 00001110b ;char 8 of CGRAM

.end





List of 70 messages in thread
TopicAuthorDate
LCD Help needed            01/01/70 00:00      
   as replied in parallel thread            01/01/70 00:00      
   try this...            01/01/70 00:00      
      Not this bit            01/01/70 00:00      
         I do both software and hardware.            01/01/70 00:00      
            diffference            01/01/70 00:00      
   What assembler??            01/01/70 00:00      
   No Initializatoin            01/01/70 00:00      
      Wait There it is.            01/01/70 00:00      
   Ah lcd problems!            01/01/70 00:00      
   Hardware problem?            01/01/70 00:00      
      Well i think its the Hardware + Software problem            01/01/70 00:00      
         Half of display            01/01/70 00:00      
            8 bit initialization            01/01/70 00:00      
               This is New Program            01/01/70 00:00      
                  nothing new            01/01/70 00:00      
                     Well sir Erik there is my code commented            01/01/70 00:00      
                        sparsely and nit using <pre> and </pre>            01/01/70 00:00      
                           It's not that difficult            01/01/70 00:00      
                              Well its not being good            01/01/70 00:00      
                                 OK, down to brass tacks and babysteps            01/01/70 00:00      
            Right Sid of LCD is Fading            01/01/70 00:00      
         normal?            01/01/70 00:00      
      LCD's vary, and contrast voltage is NEGATIVE!            01/01/70 00:00      
         sometimes            01/01/70 00:00      
            I heard that once ...            01/01/70 00:00      
         HUH?            01/01/70 00:00      
            guilty as charged            01/01/70 00:00      
               two            01/01/70 00:00      
                  I reuse mine            01/01/70 00:00      
   try this one            01/01/70 00:00      
      why try something that can not be unbderstood            01/01/70 00:00      
   Solve            01/01/70 00:00      
      Nothing is happining with New LCD also            01/01/70 00:00      
         Sorry guys...            01/01/70 00:00      
         Try            01/01/70 00:00      
            Well sir I am using HD44780            01/01/70 00:00      
               sloooow down coders            01/01/70 00:00      
   TESTED code for LCD            01/01/70 00:00      
      It may be tested..            01/01/70 00:00      
         blame            01/01/70 00:00      
            Circuit configuration for LCD interfacing            01/01/70 00:00      
               P1.x control?            01/01/70 00:00      
                  No problem with pin configuration            01/01/70 00:00      
                     Well i have changed Pin configuration back            01/01/70 00:00      
                        Pullups on P1.0,1            01/01/70 00:00      
                           about P1.0 and P1.1            01/01/70 00:00      
                        Does your micro work at all?            01/01/70 00:00      
                           to be specific...            01/01/70 00:00      
                        my issue            01/01/70 00:00      
      debugging            01/01/70 00:00      
   Finally i have did it.....            01/01/70 00:00      
      go high            01/01/70 00:00      
   Code for 8-Bit LCD (HD44780)            01/01/70 00:00      
      perfect            01/01/70 00:00      
         Perfect for some...            01/01/70 00:00      
            it is important with the at89c2051            01/01/70 00:00      
               i am noob, so dont worry about pins :-)            01/01/70 00:00      
                  no encryption required            01/01/70 00:00      
               Real world            01/01/70 00:00      
                  answer            01/01/70 00:00      
                     Is this true?            01/01/70 00:00      
                        To some people it seems            01/01/70 00:00      
                           kindof            01/01/70 00:00      
                              You can get by with this some of the time            01/01/70 00:00      
                              Point missed            01/01/70 00:00      
                                 check this            01/01/70 00:00      
                                    You didn't take the challenge            01/01/70 00:00      
   why should you            01/01/70 00:00      
   Help on LCD code            01/01/70 00:00      

Back to Subject List