i have tried programming my lcd but it does not work and i cant understand were i have gone wrong with my code,
,my code is shown belw
<;********************************************************** ;; Application Note: ; ================= ; Displaying Characters on an LCD Character Module ; ; Description: Demo software to display “canned†;message and custom characters. ; Controller: Phillips 87C751 ; LCD controller: HD44780, KS0066, SED1278 ; ;************************************************************* ; Constant Definition ;*************************************************************
;***************************************** ; Port Connections ; ================= ; P1.0 -> D0 ; P1.1 -> D1 ; P1.2 -> D2 ; . . . ; P1.7 -> D7 ; P2.2 -> Enable ; P2.0 -> RS ; P2.1 -> RW ;******************************************************* ; Interrupt Vectors ; ------------------ org 000h jmp PowerUp ; Power up reset vector
PowerUp: ;************************************** ; LCD Initialization Routine ;************************************** cinit: clr P3.1 ;RS low clr P2.1 ;RW low setb P2.2 ;Enable mov p1,#38h acall command_byte acall ddelay ;initial delay 4.1mSec mov p1,#38h ;function set acall command_byte acall ddelay ;busy flag not avail. yet mov p1,#38h ;function set acall command_byte mov p1,#0ch ;display on acall command_byte mov p1,#01h ;clear display acall command_byte acall cgram ;define custom fonts acall first_line ;display first line acall second_line ;display second line sdone: jmp sdone ;******************************************************** ;Subroutine: WRITE ;================= ;Purpose: To feed in data/command bytes to the LCD module ;Parameters:dptr = should be set to the beginning of ; the data byte address ; Data bytes should be finished with 99H ;Alg: get a new data/command byte ; while (new data != 99h) { ; set port1 with new data ; call data_byte ; increment data pointer ; } ; return ;******************************************************** write: write_loop: mov a,#0 movc a,@a+dptr cjne a,#99h,write_cont ret write_cont: mov p1,a acall data_byte inc dptr jmp write_loop ;************************************************ ; Delay Routine: ; Delay periond = Ims ;************************************************ ddelay: PUSH ACC MOV A,#0A6H MD_OLP: INC A NOP NOP NOP NOP NOP NOP NOP NOP JNZ MD_OLP NOP POP ACC RET MADELAY: PUSH ACC MOV A,#036H MAD_OLP: INC A NOP NOP NOP NOP NOP NOP NOP NOP JNZ MAD_OLP NOP POP ACC ret ;******************************** ; set address to beginning ; of CG RAM ;******************************** cgram: mov p1,#40h acall command_byte mov dptr,#cgram_data acall write ret ;******************************** ; Set DDRAM to the beginnig of ; the first line - 00 ;******************************** first_line: mov p1,#080h ;set DDRAM acall command_byte mov dptr,#fline_data acall write ret ;******************************** ; Set DDRAM to the beginning of ; the second line - 40 ;******************************** second_line: mov p1,#0c0h ;set DDRAM acall command_byte mov dptr,#sline_data acall write ret ;********************************************************** ; Feed Command/Data to the LCD module ;*********************************************************** command_byte: clr p2.0 ; RS low for a command byte. jmp bdelay data_byte: setb p2.0 ; RS high for a data byte. nop bdelay: clr p2.1 ; R/w low for a write mode clr p2.2 nop setb p2.2 ;enable pulse nop ;******************* Check Busy Flag mov p1,#0ffh ;configure port1 to input mode setb p2.1 ;set RW to read clr p2.0 ;set RS to command clr p2.2 ;generate enable pulse nop setb p2.2 bloop: nop mov a,p1 anl a,#80h ;check bit#7 busy flag cjne a,#00h,bloop;keep waiting until busy flag clears ;***************************************** ; check busy flag twice ;***************************************** bwait: mov a,p1 anl a,#80h cjne a,#00h,bloop clr p2.1 ;return to write mode ret ;******************************************** ; Data Bytes ;******************************************* FLINE_DATA: db '>>8051projects<<' db 099h SLINE_DATA: db 00h,01h,02h,03h,04h,05h,06h,07h db 099h CGRAM_DATA: font1: db 0ah,15h,11h,11h,0ah,04h,00h,00h font2: db 04h,0ah,11h,11h,15h,0ah,00h,00h font3: db 04h,0eh,15h,04h,04h,04h,04h,00h font4: db 04h,04h,04h,04h,15h,0eh,04h,00h font5: db 18h,18h,1fh,1fh,1fh,18h,18h,00h font6: db 1fh,1fh,03h,03h,03h,1fh,1fh,00h font7: db 0ah,15h,0ah,15h,0ah,15h,0ah,00h font8: db 15h,0ah,15h,0ah,15h,0ah,15h,00h db 99h end >
thanks