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 interfacing with PIC16F877A based developement board

Status
Not open for further replies.

ccslearner

Junior Member level 1
Junior Member level 1
Joined
Feb 1, 2013
Messages
19
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Location
India,tamilnadu
Visit site
Activity points
1,445
Hello edaboard members,
I just try to interface my LCD 2*16 line with PIC16F877A developement board .i connect all the wires correctly but i am trouble in giving power supply to lcd . where i can get from power supply through MCU or breadboard so please guide me i attached my developement board schematic and PIC C compiler
Code:
///////////////////////////////////////////////////////////////////////////
////                             LCD.C                                 ////
////                 Driver for common LCD modules                     ////
////                                                                   ////
////  lcd_init()   Must be called before any other function.           ////
////                                                                   ////
////  lcd_putc(c)  Will display c on the next position of the LCD.     ////
////                     The following have special meaning:           ////
////                      \f  Clear display                            ////
////                      \n  Go to start of second line               ////
////                      \b  Move back one position                   ////
////                                                                   ////
////  lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1)    ////
////                                                                   ////
////                                                                   ////
///////////////////////////////////////////////////////////////////////////
#define RS PIN_C0
#define RD_WRT PIN_C1
#define ENABLE PIN_C2
#BYTE PORTC=0x7   // C4,C5,C6,C7

#define LCD_ROW_1 1
#define LCD_ROW_2 2

#define LCD_LINE_TWO 0x40    // LCD RAM address for the second line
BYTE const LCD_INIT_STRING[4] = {0x28, 0xc, 1, 6};                        //const = Data is read-only.  Depending on compiler configuration,
                                                                          // this qualifier may just make the data read-only -AND/OR- it may place the data
                                                                          // into program memory to save space. (see #DEVICE const=)                
                            // These bytes need to be sent to the LCD
                            // to start it up.
extern unsigned char dispbuf[16];

const unsigned char welcome_mess_1[17] = {" Hi Prabhu      "};
const unsigned char welcome_mess_2[17] = {"Welcome toindia "};
void lcddisplay(int8);

void lcd_send_nibble( BYTE n ) 
{
  PORTC =  (PORTC & 0x0f) | (n<<4);
  delay_cycles(1);
  output_high(enable);
  delay_us(2);
  output_low(enable);
  delay_ms(2);
}

void lcd_send_byte( BYTE address, BYTE n ) 
{
  output_low(rs);
  delay_cycles(3);//added
  delay_us(1);//added
  
  if ( address & 0x01)
    output_high(rs);
  else
    output_low(rs);
        
  delay_cycles(1);
  delay_cycles(1);
  output_low(enable);
  lcd_send_nibble(n >> 4);
  lcd_send_nibble(n & 0xf);
}

void lcd_init(void) 
{
  int8 i=0;
  set_tris_c(0x00);
  delay_ms(15);
  
  output_low(RD_WRT);
  output_low(rs);
  output_low(enable);
  
  lcd_send_nibble(3); // send 8 bit long

  delay_ms(5);

  lcd_send_nibble(3); // send 8 bit long

  delay_ms(1);

  lcd_send_nibble(3); // send 8 bit long

  delay_ms(1);

  lcd_send_nibble(2);

  for(i=0;i<=3;++i)
  lcd_send_byte(0,LCD_INIT_STRING[i]);
}


void lcd_gotoxy( BYTE x, BYTE y) 
{
  BYTE address;
  if(y!=1)
    address=LCD_LINE_TWO;
  else
    address=0;
  address+=x-1;
  lcd_send_byte(0,0x80|address);
}

void lcd_putc( char c)
{
  switch (c) 
  {
    case '\f'   : lcd_send_byte(0,1);
                  delay_ms(2);
                  break;
    case '\n'   : lcd_gotoxy(1,2);  
                   break;
    case '\b'   : lcd_send_byte(0,0x10); 
                   break;
    default     : lcd_send_byte(1,c);   
                   break;
  }
}

////////////////////  ADDED ///////////////////
// This is the welcome message shown to LCD display
// when the power is coming up
void shwmess(void)   
{
  BYTE i;
  
  for(i=0;i<=15;i++)
  dispbuf[i]=welcome_mess_1[i];
  
  lcddisplay(LCD_ROW_1); 
      
  for(i=0;i<=15;i++)
  dispbuf[i]=welcome_mess_2[i];
  
  lcddisplay(LCD_ROW_2); 
}

// write the dispbuf data to LCD display 
// based on the row number passed to function
void lcddisplay(int8 row_no)
{
   BYTE i=0;
   
   if(row_no == LCD_ROW_1)
     lcd_gotoxy(1,1);
   else
     lcd_gotoxy(1,2);
   
   for(i=0;i<=15;i++)
   lcd_putc(dispbuf[i]);
}
 

Attachments

  • labx2.pdf
    49.4 KB · Views: 95

u can apply separate supply connection to LCD as well as controller but their ground must be common.

thanks for breadboard, wiring is it corrct?????
PIC16F877A --> 11th pin(5v) is connected to positive rail of the breadboard
one more wire is connected between positive rail of the breadboard to Positive terminal Point A
12th pin(GND) is conected to negative rail of the breadboard and this negative rail connected to another ground of the bread board
through another wire
LCD----------->PIN1(GND) Is connected to common negative rail of the breadboard
PIn2(5v) is connced to breadboard positive point A

please verify it because am afraid to give power supply to my development board
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top