??? 01/09/05 20:17 Read: times |
#84609 - LCD display problems |
Hi, I am using some bits of code I threw together from your tutorial section. When I run the program the display reads correctly but appears to have a raster scan through the display. When I load up another lcd program I downloaded from a site and it works perfectly.
This leads me to believe my program is software related. This is the program I pieced together myself. Can anyone advise if the problem is in my code. Thanks James Krushlucki ; LCD Example Program ; Works with P1 as data port, R/W connected to P3.2, Enable to P3.4, RS to P3.3 ;***** #INCLUDE "8051EQU.INC" ;include predefined constants ; ;************************************************************************** ; VARIABLES AND CONSTANTS ; DB0 .EQU P1.0 DB1 .EQU P1.1 DB2 .EQU P1.2 DB3 .EQU P1.3 DB4 .EQU P1.4 DB5 .EQU P1.5 DB6 .EQU P1.6 DB7 .EQU P1.7 EN .EQU P3.4 RS .EQU P3.3 RW .EQU P3.2 DATA .EQU P1 ; ;************************************************************************** ; ; RESET ;reset routine ; .ORG 0H ;locate next command at 00H AJMP START ;jump to START (first command of program) ; ;************************************************************************** ; ; INTERRUPTS ;place interrupt routines at appropriate ;memory locations .ORG 03H ;external interrupt 0 RETI .ORG 0BH ;timer 0 interrupt RETI .ORG 13H ;external interrupt 1 RETI .ORG 1BH ;timer 1 interrupt RETI .ORG 23H ;serial port interrupt RETI .ORG 2BH ;locate beginning of rest of program ; ;************************************************************************** ; INITIALIZE: ;set up control registers ; MOV TCON,#00H MOV TMOD,#00H MOV PSW,#00H MOV IE,#00H ;disable interrupts RET ;************************************************************************** INIT_LCD: ; SETB EN CLR RS MOV DATA,#30h ;NUMBER OF LINES, FONT SIZE AND DATA BITS CLR EN LCALL WAIT_LCD SETB EN CLR RS MOV DATA,#0Ch ;DISPLAY, CURSOR AND BLINK ON/OFF, CLR EN LCALL WAIT_LCD SETB EN CLR RS MOV DATA,#010h ;CURSOR SHIFT, LEFT OR RIGHT CLR EN LCALL WAIT_LCD RET ; CLEAR_LCD: ; SETB EN CLR RS MOV DATA,#01h CLR EN LCALL WAIT_LCD RET ; WRITE_TEXT: ; SETB EN SETB RS MOV DATA,A CLR EN LCALL WAIT_LCD RET ; WAIT_LCD: ; SETB EN ;Start LCD command CLR RS ;It's a command SETB RW ;It's a read command MOV DATA,#0FFh ;Set all pins to FF initially MOV A,DATA ;Read the return value JB ACC.7,WAIT_LCD ;If bit 7 high, LCD still busy CLR EN ;Finish the command CLR RW ;Turn off RW for future commands RET ; START: LCALL INITIALIZE LCALL INIT_LCD LCALL CLEAR_LCD MOV A,#'H' LCALL WRITE_TEXT MOV A,#'E' LCALL WRITE_TEXT MOV A,#'L' LCALL WRITE_TEXT MOV A,#'L' LCALL WRITE_TEXT MOV A,#'O' LCALL WRITE_TEXT MOV A,#' ' LCALL WRITE_TEXT MOV A,#'W' LCALL WRITE_TEXT MOV A,#'O' LCALL WRITE_TEXT MOV A,#'R' LCALL WRITE_TEXT MOV A,#'L' LCALL WRITE_TEXT MOV A,#'D' LCALL WRITE_TEXT .END |
Topic | Author | Date |
LCD display problems | 01/01/70 00:00 | |
Raster Scan | 01/01/70 00:00 | |
Program looping. | 01/01/70 00:00 | |
.end | 01/01/70 00:00 | |
Re: .end![]() | 01/01/70 00:00 |