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.

problem with my 16x2 LCD (second row doesnt have output)

Status
Not open for further replies.

aimiaisyah

Newbie level 3
Joined
Oct 27, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
hi...i am newbie here...

i want to ask about my problem displaying my result in both 1st and second line....but the answer only appear on the 1st line only..

this was taken from some website that use 18f4550, but im trying to modify to use 18f452...im using proteus to simulate this project..

Code:
#include <p18f452.h>
#include <adc.h>
#include <stdlib.h>
#include <delays.h>
#include "bootlcd.h"

#pragma config WDT = OFF
#pragma config OSC = XT

void low_isr(void);
void high_isr(void);

#pragma code low_vector=0x2018
void interrupt_at_low_vector(void)
{
  _asm GOTO low_isr _endasm
}
#pragma code 

#pragma code high_vector=0x2008
void interrupt_at_high_vector(void)
{
  _asm GOTO high_isr _endasm
}
#pragma code 

#pragma interruptlow low_isr
void low_isr (void)
{
  
 return;
}

#pragma interrupt high_isr
void high_isr (void)
{
 return;
}


void DelayFor18TCY( void )
{
 Delay10TCYx(2);        // 5us delay
 return;
}
void DelayPORXLCD (void)
{
  Delay1KTCYx(75); // Delay of 15ms
                   // Cycles = (TimeDelay * Fosc) / 4
                   // Cycles = (15ms * 20MHz) / 4
                   // Cycles = 75,000
  return;
}
void DelayXLCD (void)
{
  Delay1KTCYx(25); // Delay of 5ms
                   // Cycles = (TimeDelay * Fosc) / 4
                   // Cycles = (5ms * 20MHz) / 4
                   // Cycles = 25,000
  return;
}

void display_lcd (unsigned int intval)
{
	unsigned int volt;
	char out[10];

	volt = intval /  131 ;
    while(BusyXLCD());              
	SetDDRamAddr(0x00);            
	putrsXLCD("RAW : ");           
	ltoa(intval, out);              
	putsXLCD(out);               
	putrsXLCD("     ");             
    while(BusyXLCD());              
	SetDDRamAddr(0x40);             
	putrsXLCD("Volt : ");           
	itoa(volt, out);                
    while(BusyXLCD());             

if(volt>99)
	{
		WriteDataXLCD(out[0]);          
    	while(BusyXLCD());             
		WriteDataXLCD('.');             
    	while(BusyXLCD());              
		WriteDataXLCD(out[1]);          
    	while(BusyXLCD());              
		WriteDataXLCD(out[2]);          
	}

else if(volt>9)
    {
		WriteDataXLCD('0');             
    	while(BusyXLCD());              
		WriteDataXLCD('.');             
    	while(BusyXLCD());              
		WriteDataXLCD(out[0]);          
    	while(BusyXLCD());              
		WriteDataXLCD(out[1]);          
	}
     
else
	{
		WriteDataXLCD('0');             
    	while(BusyXLCD());              
		WriteDataXLCD('.');             
    	while(BusyXLCD());              
		WriteDataXLCD('0');             
    	while(BusyXLCD());              
		WriteDataXLCD(out[0]);          
	}

	putrsXLCD("V     ");               
}


void main( void )
{
  char temdata;
  
  unsigned int current_ad_value;
  TRISAbits.TRISA0 = 1;
  
  ADCON0bits.ADCS0 = 1;                 // FOSC/32 clock select , left alignment
  ADCON0bits.ADCS1 = 1;
  ADCON1bits.ADCS2 = 1;
  ADCON1bits.ADFM = 0;

  
  ADCON1 = 0b00000000;                  // interal ref 
 
  ADCON0bits.ADON = 1;                  // Turn on the ADC

  OpenXLCD();                           // configure external LCD

  while(1)
  {
         
      Delay100TCYx (2);                 // Give the ADC time to get ready.
    
      ADCON0bits.GO = 1;                // start the ADC conversion
      
   while (ADCON0bits.GO);
      current_ad_value = ADRES;
	  display_lcd(current_ad_value);
      Delay10KTCYx (200);
  }

}



the SetDDRam code is (0x80)


when i set my first and second data adress : (0x00) and (0x40) the result appear like this:
**broken link removed**

when i set my first and second data adress : (0x00) and (0x80) the result appear like this:
**broken link removed**
 
Last edited by a moderator:

I think your problem is with the LCD character RAM. The top line adresses do not flow into the lower one, Try adding an offset to the address to get the lower row, depending on the type of LCD it is usually 20 or 40.
You may also have to send configuration data to the LCD controller to tell it how many lines there are on the panel.

Brian.
 

TRY 0x80 and 0xC0 commands for setting first line and second line
and for config you should have given 0x38
 

im using Lm016L for the simulation..i dont knopw how to add an offset and send the data to the LCD...really need a help..

i have try put 0x80 and 0xC0 commands for setting first line and second line, but the problem remain the same..about the config, is it the SetDDRam? if yes,i also have change from SetDDRamAddr(0x80) to SetDDRamAddr(0x38) but the problem remain the same

i have read the datasheet of LCD that require to change N to 1 if i want to have 2 line display,but i dont know which one is N??

// Set data interface width, # lines, font
while(BusyXLCD()); // Wait if LCD busy
WriteCmd8bit(FOUR_BIT & LINES_5X7); // Function set cmd
while(BusyXLCD());

From my understanding,LINES_5X7 already represent multilines display..

pleasee.....help me....im really dont know how to solve it
 

This happened to me also several time, Check the lcd initialization function,or check the delay between each commands. Did you checked on Proteus simulator.
 

you can try 0x80 to 8f for first line.
and 0xco to 0xcf for second line.
u can also try to initialze lcd 2-3 time.0x38,0x38,0x38,0x38.
 
Last edited:

can u show me the correct way to initialize the lcd?i have try all the method but it still didn't work..
proteus simulation gives for the 1st line (0X80) and second line (0XC0)...already change but still the same..

pleasee....help me...i really need a help :-(...i'm totally newbie in c programming...
 

Code:
#include<reg51.h>
#include<stdlib.h>


sbit RS = P2^0;
sbit RW = P2^1;
sbit EN = P2^2;

void lcd_setting(void);
void lcd_command(unsigned char);
void lcd_data(unsigned char);
void smalldelay (void); // function prototype



void delay (unsigned int dly)
{
 unsigned int dl=0;
 for(dl=0;dl<dly;dl++);
}

void main(void)
{

lcd_setting();
delay(100);
lcd_command(0x8f);
delay(10);
lcd_data('P');
delay(10);
lcd_data('A');
delay(10);
lcd_data('W');
delay(10);
lcd_data('A');
delay(10);
lcd_data('N');
delay(10);
lcd_command(0xcf);
delay(10);
lcd_data('P');
delay(10);
lcd_data('A');
delay(10);
lcd_data('W');
delay(10);
lcd_data('A');
delay(10);
lcd_data('N');
delay(10);
while(1)
{
 lcd_command(0x18);
 delay(5000);
 delay(5000);
 delay(5000);
}

}

void lcd_setting(void)
{
lcd_command(0x38);
delay(50);
lcd_command(0x0e);
delay(50);
lcd_command(0x06);
delay(50);
lcd_command(0x01);
delay(50);
lcd_command(0x80);
delay(50);

}



void lcd_command(unsigned char CMD )
{
P0=CMD;
RS=0; // for command register select 0
RW=0;
EN=0;
EN=1;
smalldelay();
EN=0;
}




void lcd_data(unsigned char DAT)
{
P0 =DAT;
RS=1;// for command register select 1
RW=0;
EN=0;
EN=1;
smalldelay();
EN=0;
}

void smalldelay (void)
{

}


---------- Post added at 07:25 ---------- Previous post was at 07:24 ----------

It is working programm it is helpful to you.
 
Last edited by a moderator:

    V

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top