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.

[PIC] lcd interfacing with pic 16f877a

Status
Not open for further replies.

msanwer

Newbie level 2
Joined
Sep 19, 2019
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
25
hi dear,

i am new to pic and ccs compiler. i write a code for lcd interfacing and simulating on the proteus. lcd showes nothing. guide me please what and where is the error? the code is as following;

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "C:\Program Files\PICC\lcd1.h"
 
#define LCD_RS_PIN PIN_C0
#define LCD_RW_PIN PIN_C1
#define LCD_ENABLE_PIN PIN_C2
#define LCD_D4 PIN_C3
#define LCD_D5 PIN_C4
#define LCD_D6 PIN_C5
#define LCD_D7 PIN_C6
//End LCD module connections
 
//#include <16F877A.h>
#use delay(crystal=20000000)
 
#include <lcd1.c>
 
void main(){
set_trix_c(0x00);
  lcd_init();    // Initialize LCD module
  
  while(TRUE){
    lcd_putc('\f');
    lcd_gotoxy(4, 1);           // Go to column 4 row 1
    lcd_putc("PIC16F877A");
    delay_ms(2000);
    
  
   }
}



kind regards
msanwer
 

your lcd_init() function should have the 4bit interface and the number of lines in the display related code plus other mode set codes.

otherwise lcd will not display the characters.
 
hello,

check if
lcd_putc(xxxx); is a function to printout a single character (byte) or a string ( serie of byte + zero)
 

hi dear,
how to check whether lcd_init() is 4 bit or 8 bit interfaced?
 

If the LCD only has 4 data lines connected to the PIC it is a 4-bit interface, if it has 8 data lines connected it is an 8-bit interface.
Note that the commands and characters are always 8-bit, if you use 4-bit mode it sends the high four bits and low four bits as two transfers instead of one.

Brian.
 

Hello,


at first, gives answer to whom want to help you !
lcd_putc(xxx) can't be used for a simple char AND/OR a string
you need 2 separate functions.

the only way is to know the detail of the lcd_init() function
your can analyse the *.asm or *.lst file resulting after compiling the source

the best way , is to write yourself this Lcd_init function .
A LCD is in 8 bit mode by default,
then you change it by 4 bit mode...

Code:
void LCD_Cmd(Byte Cde)
{   Byte D2;
    LCD_RS = 0;
    // envois poid fort
     D2 = Cde >> 4;
     LCD_RS = 0;        
    Transmet (D2);
// envois poid faible
    D2= Cde & 0x0F;
     LCD_RS = 0;        
    Transmet (D2);
}


void Init_LCD_2X16(void)
{
    Byte Cde;

    LCD_E  = 0;
    LCD_RW = 0;
    LCD_RS = 0;
    Cde= 0x30;             // Mode 8 bit
    LCD_Cmd(Cde);
    DELAY_15MS;

    Cde= 0x30;             // Mode 8 bit
    LCD_Cmd(Cde);        // MSB
    Delay_2Ms;
    LCD_Cmd(Cde);        // MSB
    Delay_2Ms;
    LCD_Cmd(Cde);        // MSB
    Delay_2Ms;

    Cde= 0x20;            // mode 4 bit sur B4..B7
    LCD_Cmd(Cde);            


    // 2 lignes , carac 5x7  =0x28
    Cde= 0x20;                        
    LCD_Cmd(Cde);    
    Cde= 0x80;                            
    LCD_Cmd(Cde);                    
    Delay_2Ms;
    // no cursor
    Cde= 0x00;
    LCD_Cmd(Cde);
    Cde = 0x0C;                    
    LCD_Cmd(Cde);
    Delay_2Ms;    // delais de 2ms

    //efface display
    Cde = 0x00;
    LCD_Cmd(Cde);
    Cde = 0x01;                        
    LCD_Cmd(Cde);
    Delay_2Ms;    // delais de 2ms

}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top