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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/26/00 20:12
Read: times


 
#1957 - LCD in 4bit mode problem
Hi there
Im trying to get a standard 16*1 lcd text module get working with my 80C535 board, but there is something wrong, i have checked the cables and all the declarations in my header file 4lcd.h
the code may look kind off messy but i just want to get it going before i optimize it.

When i turn the power on the display turn on both halves of the display and that must mean that the first command is sucessful. After that nothing more happens no text comes upp and no cursor

What can be wrong?
The program doesnt hang up i know that it ends up in the while(1) loop

Enable = Bit2,P4 = LCD_E
R/W = Bit1,P4 = LCD_RW
RS = Bit0,P4 = LCD_RS

LCD_PORT = P4
Here is the code:

;===================================

#include <4lcd.h>
void init_LCD(void);
void LCD_WRCMD(unsigned char cmd);
void LCD_WRDATA(unsigned char data);
void wait(void);

void main(void) {
init_LCD();
LCD_WRDATA('1');
while(1);
}

void init_LCD(void) {
LCD_PORT=0x0;

wait();
wait();

LCD_PORT=0x20;
LCD_E=1;
LCD_E=0;
wait();

LCD_WRCMD(0x28);
wait();

LCD_WRCMD(0xF);
wait();

LCD_WRCMD(0x1);

wait();
wait();
wait();
wait();
wait();
}



void LCD_WRCMD(unsigned char cmd) {
_asm
mov a,_cmd
anl a,#0xF0
mov _LCD_PORT,a
setb _LCD_E
nop
clr _LCD_E
nop
nop
mov a,_cmd
swap a
anl a,#0xF0
mov _LCD_PORT,a
setb _LCD_E
nop
clr _LCD_E

orl _LCD_PORT,#0xF0
setb _LCD_RW

C1: setb _LCD_E
mov c,_LCD_BUSY
clr _LCD_E
nop
setb _LCD_E
nop
clr _LCD_E
jc C1


_endasm;

}

void LCD_WRDATA(unsigned char data) {
_asm
mov a,_data
anl a,#0xF0
mov _LCD_PORT,a
setb _LCD_RS
setb _LCD_E
nop
clr _LCD_E
mov a,_data
swap a
anl a,#0xF0
mov _LCD_PORT,a
setb _LCD_RS
setb _LCD_E
nop
clr _LCD_E

orl _LCD_PORT,#0xF0
setb _LCD_RW
clr _LCD_RS


D1: setb _LCD_E
nop
mov c,_LCD_BUSY
clr _LCD_E
nop
setb _LCD_E
nop
clr _LCD_E
jc D1


_endasm;

}

void wait(void) {
_asm
mov r0,#0
mov r1,#100

Q6: nop
nop

djnz r0,Q6
djnz r1,Q6
_endasm;

}


List of 8 messages in thread
TopicAuthorDate
LCD in 4bit mode problem            01/01/70 00:00      
RE: LCD in 4bit mode problem            01/01/70 00:00      
RE: LCD in 4bit mode problem            01/01/70 00:00      
RE: LCD in 4bit mode problem            01/01/70 00:00      
RE: LCD in 4bit mode problem            01/01/70 00:00      
RE: LCD in 4bit mode problem            01/01/70 00:00      
RE: LCD in 4bit mode problem            01/01/70 00:00      
RE: LCD in 4bit mode problem            01/01/70 00:00      

Back to Subject List