free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
say2paul
Thu Jul 03 2008, 10:30AM
 User Offline
Registered Member #8461
Joined: Tue Jun 17 2008, 10:56AM

Posts: 123
Thanked 6 times in 6 posts
Please look at the following code and let me know where I am wrong? In the following code I am not using the BF flag instead I am providing a delay using for loop (12 MHz).

The output is sometimes printed well on the LCD but sometimes it just print the first line and does not print the second line.

Can anyone help me rectifying it?

CODE:

/*********************************************************  
*    PROGRAM TO TEST LCD INTERFACE                                       *

*    ADDRESS OF LED'S = 0XFD00                                                   *
*********************************************************/

         
#include<P89V51RX2.h>
#include<intrins.h>
#include<string.h>

/*********************************************************
Function Prototypes
*********************************************************/

void delay(void);
void writecommand(unsigned char);
void writedata(unsigned char);
void printlcd(unsigned char *);
void nextline(void);
/*********************************************************/


xdata volatile unsigned char rs _at_ 0xFE01;
//xdata volatile unsigned char en _at_ 0xFE00;
xdata volatile unsigned char lcd _at_ 0xFE00;



/*********************************************************
Function which causes some  delay
*********************************************************/

void delay()
{
int k;
for(k=0;k<=9000;k++);
}
/*********************************************************/


/*********************************************************
Function to initialize lcd
*********************************************************/

void init_lcd()
{
writecommand(0x38);
writecommand(0x06);
writecommand(0x0e);

writecommand(0x01); //Clear the display

}

/*********************************************************/


/*********************************************************
Function to write data into lcd
*********************************************************/

void writecommand(unsigned char data1)
{
lcd=data1;
//en=1;
//en=1;
_nop_();
_nop_();
//en=0;
delay();
}
/*********************************************************/

void writedata(unsigned char data2)
{
rs=data2;
//en=1;
//en=1;
_nop_();
_nop_();
//en=0;
//delay();
}

/*********************************************************
Function to print a string data into lcd
*********************************************************/


 void printlcd(unsigned char *str)
{
unsigned char len,i;

//rs=1;

len=strlen(str);

        for(i=1;i<=len;i++)
        {
        writedata(*str);
        str++;
        }
}

/*********************************************************/



/*********************************************************
Function to send a command to print in 2nd line
*********************************************************/


void nextline()
{
//rs=0;
writecommand(0xc0);
}

/*********************************************************/


void main()
{

AUXR=0x03;
//rw=0;                        //read/write pin made 0

init_lcd();                          //initialize lcd

printlcd("Hello how r u?");              //send a string for display

nextline(); // Next Line

printlcd("I am fine");           //send a string for display

while(1);

}
 


Back to top


Amin Sharif
Thu Jul 03 2008, 08:35PM
 User Offline
Registered Member #6421
Joined: Mon Mar 03 2008, 11:44PM

Posts: 31
Thanked 0 times in 0 posts
Hello

increase the delay to about 15 to 20 mili seconds.
Give delay in Write data command routine too.
Back to top


say2paul
Thu Jul 03 2008, 10:18PM
 User Offline
Registered Member #8461
Joined: Tue Jun 17 2008, 10:56AM

Posts: 123
Thanked 6 times in 6 posts
If I give more delay then it does not look nice when the display shifts left or right.

Can anyone tell me how to achieve the following feature in 2 line LCD:

- Line 1 display shift left.
- Line 2 display shift right.

or

- Line 1 display no shift.
- Line 2 display shift right.

Back to top


Ajay
Thu Jul 03 2008, 11:28PM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 4035
Thanked 751 times in 710 posts
use an array and rotate it..

shift that array left or right one byte or say one element, display on LCD, then give some delay before shifting the next element.

you can do this shift as you want. IT Pro wont have any problem doing it

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


say2paul
Fri Jul 04 2008, 02:07AM
 User Offline
Registered Member #8461
Joined: Tue Jun 17 2008, 10:56AM

Posts: 123
Thanked 6 times in 6 posts
Smart!! but I was talking about the display shift commands.

Suppose I give right shift command to the LCD, both the lines start moving in the right direction, but I want only one line to move and other to stay intact.

So, its display shift commands

[ Edited Fri Jul 04 2008, 02:08AM ]
Back to top


Ajay
Mon Jul 07 2008, 07:52AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 4035
Thanked 751 times in 710 posts
well display shift will shift the entire display (behind the scene.. it shift the ram content in cyclic way) so its not possible to shift a single line.

only possible with software...

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems