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.

LCD not initailzing when connected to PIC16F877A

Status
Not open for further replies.

jean12

Advanced Member level 2
Joined
Aug 27, 2013
Messages
529
Helped
5
Reputation
12
Reaction score
6
Trophy points
18
Activity points
5,497
Hello,could you please help me to know why my LCD is not getting initialized?
I am using microc v6.6.3 but the LCD is only showing the first line of black squares nothing else,when adjusting the potentiomter for brightness nothing changes about characters only the black squares disappear .

Could you please help me to detect this problem?
Here are my codes:
PHP:
unsigned char ch;
unsigned max_point0 = 0;
unsigned int i,tlong0,tlong1;
char *volt="00.0";
//char *current="0.00";
unsigned int a;

// LCD module connections
sbit LCD_RS at RC2_bit;
sbit LCD_EN at RC3_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;

sbit LCD_RS_Direction at TRISC2_bit;
sbit LCD_EN_Direction at TRISC3_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;

char look(int a)
{
  switch(a)
  {
    case 0:
      return '0';
    case 1:
      return '1';
    case 2:
      return '2';
    case 3:
      return '3';
    case 4:
      return '4';
    case 5:
      return '5';
    case 6:
      return '6';
    case 7:
      return '7';
    case 8:
      return '8';
    case 9:
      return '9';
    default:
      return '.';
  }
}
void main()
{
  PORTC=0;
  TRISC=0x00;
   LCD_init();
    Lcd_Cmd(_LCD_CLEAR);
     Lcd_Cmd(_LCD_CURSOR_OFF);
 while(1)
 { 
     Lcd_out(2,1,"DVM Project");
     delay_ms(1500);
 
 }
 
 }









/*TRISA = 0b00011111;
 TRISC = 0x00;
 TRISD=0X00;
 PORTD=0;
 PORTC=0;
 ADCON1=0x00;
 OPTION_REG = 0b00101000;
 delay_us(50);
 Lcd_Init();
  Lcd_Cmd(_LCD_CLEAR);
  Lcd_Cmd(_LCD_CURSOR_OFF);
Delay_us(20);

 while(1)
 {
 
 PORTD.B0=1;
 PORTD.B1=0;
 delay_ms(1000);
 PORTD.B1=1;
 PORTD.B0=0;
 delay_ms(1000);
 
 
   v=ADC_read(3);
     i=(i*4.89)/0.2;
     v=((v*4.89)/20)*120; //use of R1=100K and R2=20K
     if(v!=vp||i!=ip)
     vp=v;
      volt[0] = look(v/10000);
    volt[1] = look((v/1000)%10);
    volt[3] = look((v/100)%10);
 
 
     Lcd_Cmd(_LCD_CLEAR);
     Lcd_Cmd(_LCD_CURSOR_OFF);
     Lcd_out(1,1, "DVM Project");
     delay_ms(1500);
    Lcd_Out(1,1,"DC=");
    Lcd_Out(1,11,volt);
    Lcd_Out(1,15,"V");
    Delay_ms(2000);

          /*   Lcd_Cmd(_LCD_CLEAR);
             Lcd_Cmd(_LCD_CURSOR_OFF);
              Lcd_out(1,1, "Battery Charger");
              Lcd_out(2,2, "IPRC SOUTH");   */
           //  delay_ms(2000);        */

Kind Regards,
 

What frequency Crystal are you using ? 4 MHz ? If yes, in project properties set Osc type to XT. If greater than 4 MHz then set to HS.

If Watch Dog Timer is enabled then disable it.

Use IntToStr() or FloatToStr() function to convert numerical value to string for displaying on LCD.
 

I am using a quartz of 4MHZ,could you please make all corrections in the above codes?
Thank you!!
 

Zip and attach the complete mikroC project files.
 

Hi,

I can´t find the "Lcd_Init()" routine.

You say the LCD doesn´t properly initialize..so you need to verify Lcd_Init().

Klaus
 

I find with LCDs that it is also best to first give them a solid reset pulse after the power comes up/is stable, then go through the init routines for setting voltage regulation, duty cycle, etc. Otherwise it is a bit hit-or-miss
 

Just to check, but are you using an alphanumeric LCD with 2 lines, e.g. 16x2 ? I'm asking because your code addresses the 2nd line, but you mentioned something appearing on 1st line.
 

hEY,THE PROBLEM is solved the mistake was declaration of 4MHZ while I am using 12MHZ in project settings.

Thank to all of you!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top