20X4 JHD 204A LCD..
Wed Jan 07 2009, 09:27 pm
i think your 20x4 lcd is not initialized properly, this is a common mistake many newbies do, send 0x30 (30h) three times consecutively with a delay of 4.1 mS in between each send, then send 0x38 and rest of other regular commands( cursor, clear,direction etc).
reduce the init delay from 500msec to 15msec also check your busy flag checking routine.
Arun
Wed Jan 07 2009, 11:14 pm
Hey guys,
Finally got it working. Yup wot arun had pointed out about connections was right. Yes the culprit was the microcontroller socket, when i pushed the controller properly it started working properly. But still not able to understand how the 16x2 display worked :mad. And thank u guys.
Finally got it working. Yup wot arun had pointed out about connections was right. Yes the culprit was the microcontroller socket, when i pushed the controller properly it started working properly. But still not able to understand how the 16x2 display worked :mad. And thank u guys.
[ Edited Wed Jan 07 2009, 11:18 pm ]
Thu Jun 04 2009, 10:36 am
Hey guys, Im using the same LCD however I keep getting a blinking cursor, that resets the value that was entered and it keeps going back to initial position then to position entered.
Please take a look at my code and give any pointers that would help, thanks in advance:
#include "headers.h"
#define RS PORTEbits.RE0
#define RW PORTEbits.RE1
#define EN PORTEbits.RE2
void init_1(void){
ADCON1=0x0F;
TRISE=0x00;
TRISC=0x00;
PORTE=0x00;
}
void LCD_busy(void)
{
unsigned char i,j;
for(i=0;i!=50;i++)
for(j=0;j!=255;j++);
}
void LCD_init(void){
PORTC=0x38;
RS=0;
RW=0;
EN=1;
EN=0;
LCD_busy();
PORTC=0x0D;
RS=0;
RW=0;
EN=1;
EN=1;
EN=0;
LCD_busy();
PORTC=0x01;
RS=0;
RW=0;
EN=1;
EN=1;
EN=0;
LCD_busy();
PORTC=0x07;
RS=0;
RW=0;
EN=1;
EN=1;
EN=0;
LCD_busy();
}
void LCD_command(unsigned char var){
PORTC=var;
RS=0;
RW=0;
EN=1;
EN=0;
LCD_busy();
}
void LCD_data(unsigned char data){
PORTC=data;
RS=1;
RW=0;
EN=1;
Delay10KTCYx(3);
EN=0;
LCD_busy();
}
void LCD_string( unsigned char *var){
while(*var)
LCD_data(*var++);
}
void main(void){
init_1();
LCD_init();
LCD_command(0x84);
LCD_data('L');
}
Please take a look at my code and give any pointers that would help, thanks in advance:
#include "headers.h"
#define RS PORTEbits.RE0
#define RW PORTEbits.RE1
#define EN PORTEbits.RE2
void init_1(void){
ADCON1=0x0F;
TRISE=0x00;
TRISC=0x00;
PORTE=0x00;
}
void LCD_busy(void)
{
unsigned char i,j;
for(i=0;i!=50;i++)
for(j=0;j!=255;j++);
}
void LCD_init(void){
PORTC=0x38;
RS=0;
RW=0;
EN=1;
EN=0;
LCD_busy();
PORTC=0x0D;
RS=0;
RW=0;
EN=1;
EN=1;
EN=0;
LCD_busy();
PORTC=0x01;
RS=0;
RW=0;
EN=1;
EN=1;
EN=0;
LCD_busy();
PORTC=0x07;
RS=0;
RW=0;
EN=1;
EN=1;
EN=0;
LCD_busy();
}
void LCD_command(unsigned char var){
PORTC=var;
RS=0;
RW=0;
EN=1;
EN=0;
LCD_busy();
}
void LCD_data(unsigned char data){
PORTC=data;
RS=1;
RW=0;
EN=1;
Delay10KTCYx(3);
EN=0;
LCD_busy();
}
void LCD_string( unsigned char *var){
while(*var)
LCD_data(*var++);
}
void main(void){
init_1();
LCD_init();
LCD_command(0x84);
LCD_data('L');
}
Fri Jun 05 2009, 02:53 pm
in LCD_init function, try to send
PORTC=0x0C;
instead of
PORTC=0x0D;
and check again.
PORTC=0x0C;
instead of
PORTC=0x0D;
and check again.
anandjassneet like this.
Tue May 17 2011, 01:27 pm
First Line : 0x80
Second Line: 0xC0
Third Line: 0x94
Fourth Line: 0xD4
more information about this, read Basics of LCD.
http://www.8051projects.net/lcd-interfacing/basics.phpAjay Bhargav
it works
here is my AVR code for Atm16.
#include <avr/io.h> #define F_CPU 12000000 #define USART_BAUDRATE 9600 #include<compat/deprecated.h> #include<util/delay.h> #include<stdlib.h> #define comport PORTB #define dataport PORTA void LCD_intlz(void) { wrcomm(0x0C); // Display on Cursor off // wrcomm(0x01); // clear previous DDRAM content// wrcomm(0x38); // Function Set for 8-bit, 2 Line, 5x7 Dots // wrcomm(0x80); //Force cursor to the beginning of 1st line// wrcomm(0x06); //Right entry Mode// wrcomm(0x0f); // Cursor Blinking On // } void wrcomm(unsigned char command) { dataport=command; comport=0x04; _delay_ms(10); comport=0x00; } void wrdata(unsigned char data) { dataport = data; comport =0x05; _delay_ms(20); comport =0x01; } void LCD_Display(unsigned char *string) { while(*string) wrdata(*string++); } void main() { DDRA=0xff; DDRB=0xff; LCD_intlz(); wrcomm(0x80); LCD_Display(" Hello World 1"); wrcomm(0xC0); LCD_Display(" Hello World 2"); wrcomm(0x94); LCD_Display(" Hello World 3"); wrcomm(0xD4); LCD_Display(" Hello World 4"); }
[ Edited Tue May 17 2011, 02:55 pm ]
Tue May 17 2011, 02:23 pm
[ Edited Tue May 17 2011, 02:52 pm ]
Powered by e107 Forum System