Hi,
I have connected a 16X2 LCD to my 4051 on a breadboard. The P1 is connected to the data lines of the LCD in 8 bit format. RW is grounded, RS to P3.0 and E to P3.1.
I wrote a short program to send the bytes 38h, 38h, 06, 0Fh, 01 to P1 and on each byte I pulsed the E line H then L. But nothing happened on the LCD. I attached the software at below. Can anyone see what's wrong with it?
; MYLCD.asm written on 030822 ; ; P1 as LCD data and p3.0 & p3.1 as rs & e ; $mod51
LCD_data set p1 LCD_RS equ 0b0h ;p3.0 LCD_E equ 0b1h ;p3.1 ; config equ 38h ;8 bit data, 2 lines, 5x7 matrix entrymode equ 6 ;inc cursor, do not shift display combncur equ 0fh clrdsp equ 1 ; org 0000h ; reset: jmp start ; org 0100h ; start: mov p1,#0 ;set p1 dir out clr LCD_rs ;set rs L clr LCD_E ;set e L mov r0,#config ;#38 call wrlcd ;send it to LCD mov r0,#config ;#38 call wrlcd mov r0,#entrymode ;#06 call wrlcd mov r0,#combncur ;#0f call wrlcd mov r0,#clrdsp ;#01 call wrlcd loop: jmp loop ; wrlcd: push acc mov a,r0 mov p1,a clr lcd_rs ;make sure it is L setb lcd_e ;pulse lcd_e clr lcd_e call wait ;wait for 65ms pop acc ret wait: mov r2,#0ffh ;delay for a while wait0: mov r3,#0ffh wait1: nop djnz r3,wait1 nop djnz r2,wait0 ret end ;end of program
Allen
------ The next war will determine NOT who is right BUT what is left.