Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] having single error in lcd program

Status
Not open for further replies.
just the cursor blinking in the lcd...it did not write the command....can anybody clarify it to me... PrtScr capture.jpg

- - - Updated - - -

i had already posted the project files.....i didn't get any error..

- - - Updated - - -

Code:
#include<pic.h>
#include<htc.h>
 
 __CONFIG(FOSC_HS & WDTE_OFF & PWRTE_OFF & CP_OFF & BOREN_OFF & LVP_OFF & CPD_OFF & DEBUG_OFF);
 
#define _XTAL_FREQ    16000000
#define RS RE1
#define EN RE2

 
void lcd_init(void);
void lcd_command(unsigned int);
void lcd_data(unsigned int);
void lcd_print(unsigned char*);
void main()
{
    lcd_init();
    
 while(1)
 {
        
   lcd_print((unsigned char *)"HELLO");
//lcd_print('1');
    __delay_ms(1000);
   lcd_print((unsigned char *)"world");
//lcd_print('2');
    __delay_ms(1000);
    lcd_command(0x06);
 }   
    }
    void lcd_print(unsigned char array[])
    {
        unsigned char i;
        for(i=0;array[i]!='\0';i++)
        lcd_data(array[i]);
        }
        
    
    void lcd_init(void)
    {
            PORTD=0x00;
    TRISD=0x00;
        TRISE1=0;
        TRISE2=0;
        lcd_command(0x38);
        lcd_command(0x0F);
        lcd_command(0x01);
    lcd_command(0x84);
           
        
        }
        void lcd_command(unsigned int command)
        {
            RS=0;
            PORTD=command;
            EN=1;
            __delay_ms(1000);
            EN=0;
            __delay_ms(1000);
            }
    
    void lcd_data(unsigned int data)
    {
        RS=1;
        PORTD=data;
        EN=1;
        __delay_ms(1000);
        EN=0;
        __delay_ms(1000);
        }
 

THIS IS MY PROGRAM ITS WORKING IN PROTEUS BUT NOT WORKING IN DEVELOPMENT BOARD PLEASE HELP ME GUYS.

/*LCD DISPLAY INTERFACING IN PIC*/
#include<htc.h>
#include<pic16f877a.h>

#include<string.h>
#include<stdio.h>
#define _XTAL_FREQ 20e6
__CONFIG(WDTE_OFF & PWRTE_ON & BOREN_ON & LVP_OFF & CPD_OFF & CP_OFF & CPD_OFF & DEBUG_OFF);
//__CONFIG( FOSC_HS & WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF);


#define load PORTB

#define RS RC0
#define RW RC1
#define EN RC2
void delayms(unsigned int);
void lcd_cmnd(unsigned char);
void lcd_data(unsigned char);
void lcd_print(unsigned char*);
void lcd_init(void);
void main(void)
{


lcd_init();
delayms(50);
//lcd_cmnd(0X80);
//delayms(100);
lcd_print("ABCD");
delayms(50);
//lcd_cmnd(0X01);
//delayms(100);

while(1)
{

;
}
}
void lcd_print(unsigned char *myStr)
{

// while(*myStr)
lcd_data(*myStr++);
}
void lcd_init()
{
TRISB=0X00;
PORTB=0X00;
TRISC0=0;
TRISC1=0;
TRISC2=0;
load=0X00;

lcd_cmnd(0X38); // configuring LCD as 2 line 5x7 matrix
lcd_cmnd(0X0E); // Display on, Cursor blinking
lcd_cmnd(0X01); // Clear Display Screen
lcd_cmnd(0X06); // Increment Cursor (Right side)
}


void lcd_cmnd(unsigned char command)
{

RS=0;
load=command;
RW=0;
EN=1;
delayms(500);
EN=0;
delayms(1);
}



void lcd_data(unsigned char display)
{

RS=1;
load=display;
RW=0;
EN=1;
delayms(500);
EN=0;
delayms(1);
}






void delayms(unsigned int delayms)
{
unsigned int i,j;
for(i=0;i<=delayms;i++)
{
for(j=0;j<=100;j++);
}
}









/*unsigned int i=0;
while(*data)
{
load=*data++;
rs=1;
rw=0;
en=1;
delayms(1);
en=0;
if(data>=16)
lcd_cmnd(0x18); // Shift the display right side
delayms(100);

}
}*/
 

If your program is working fine in Proteus and not working on the development board, then in most cases the problem will be with the delays. Just try changing the delays. I have faced such issues where my program works fine in Proteus but not on boards.
 

you are going to write 2 chrs per second....

actually i am new to pic. i worked some projects in 8052. but i don't know how to work in pic and then i want to learn register configurations too. here i am going to write one character only.

- - - Updated - - -

but this code is not working in real hardware.
 

With hitech compiler use the predefined delay functions __delay_ms() with the definition


Code C - [expand]
1
#define _XTAL_FREQ 12000000 //ex for 12Mhz



refer the lcd datasheet for delay timings first time it shd be more than 15ms and after that 37us is enough between commands and datas.... so better allow 1ms....
 

If you want to scroll single line of LCD then the lcd data should be in a string (char array) and you have to shift the contents of the array and print it everytime after shifting the elements. Also try shifting the lcd column no. If you print "Hello" starting at 16th column then repetedly print the string decrementing the column everytime by 1. If you add delay with it then the text will scroll.



Edit: LCD Scroll commands scroll all the lines of LCD.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top