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.

I have a Problem with PIC 16F877A and LCD 2x16 .. Help Me

Status
Not open for further replies.

bas_90

Member level 1
Joined
Mar 21, 2013
Messages
35
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,503
i have a PIC 16F877A and LCD 2x16

i tested PIC Only and it's Ok :)

but when test it with LCD , LCD don't show any character !!!

what's the problem and how i can test LCD only to know if it Okay or not ?!

and what's the best Compiler working with Pic 16F877A ?!

thnx :)
 

what is your code to initialize the LCD?

MPLAB is good to start with.
 

thnx , you mean this ?!

Code:
#include <16F877A>
#include <lcd.c>
#use delay(clock=20000000)

#define en pin_d0;
#define rw pin_d2;
#define rs pin_d1;
#define d4 pin_d4;
#define d5 pin_d5;
#define d6 pin_d6;
#define d7 pin_d7;

void lcd_init()
{
    delay_ms(15);
    cmd(0x38);
    delay_ms(1);
    cmd(0x38);
    delay_us(100);
    cmd(0x38);
    cmd(0x28);             // Function set (4-bit interface, 2 lines, 5*7Pixels)
    cmd(0x28);            // Function set (4-bit interface, 2 lines, 5*7Pixels)
    cmd(0x0c);            // Make cursorinvisible
    clear();              // Clear screen
    cmd(0x6);            // Set entry Mode(auto increment of cursor)
}

void main()
{
           lcd_init();                      // LCD Display initialization
           lcd_cmd(_LCD_CURSOR_OFF);        // LCD Command (Cursor Off)

           for (;;)
           {
           printf(1,1,"Hello World");                        // Define the first message
           Delay_ms(1000);
           
           printf(2,1,"love is love");                        // Define the first message
           Delay_ms(1000);
           }

}
 

Have you also set the PIN that are connected to the LCD? I'm not sure about the coding as I don't have mine right now, but if you are using MPLAB you can use sample codes that are in the software to initialize the LCD.

EDIT : I also find it weird that you have 0x38 3 times.... check the sample code it should give tell you what is missing.
 

Have you also set the PIN that are connected to the LCD? I'm not sure about the coding as I don't have mine right now, but if you are using MPLAB you can use sample codes that are in the software to initialize the LCD.

EDIT : I also find it weird that you have 0x38 3 times.... check the sample code it should give tell you what is missing.

Can you write a simple code to Display "Hello World" only ?! thnx alot :)

- - - Updated - - -

You are mixing mikroC and CCS C codes.

o_O , Any Book to learn Programming PIC by CCS C?!
 

hello , i using MPLAB now and writing the code

show error msg when "Building"

Code:
HI-TECH C PRO for the PIC10/12/16 MCU family (Lite)  V9.65PL1
Copyright (C) 1984-2009 HI-TECH SOFTWARE
(1273) Omniscient Code Generation not available in Lite mode (warning)
(902) no chip name specified; use "PICC --CHIPINFO" to see available chip names

how can fix it ?!
 

If your code is CCS C code then you have to select CCS C as the toolsuite (compiler) in mplab. You are using Hi Tech C Compiler. Is your code for Hi Tech C Compiler? If yes, post the code so that it can be checked.
 

Ohhh o_O , first i use Hi-Tech but now CCS C Compiler

the first msg error is closed but now new error msg

the dir now for compiler is "C:\Program Files (x86)\Microchip\Third Party\PICC\Ccsc.exe"

and Code
Code:
#include <16F877A.h>
#fuses HS, NOLVP, NOWDT, NOPROTECT
#use delay(clock=20000000)
#include <lcd.c> 

#define LCD_ENABLE_PIN  PIN_B2                                    ////
#define LCD_RS_PIN      PIN_B0                                    ////
#define LCD_RW_PIN      PIN_B1                                    ////
#define LCD_DATA4       PIN_B3                                    ////
#define LCD_DATA5       PIN_B4                                    ////
#define LCD_DATA6       PIN_B5                                    ////
#define LCD_DATA7       PIN_B6

void manin()
{
char a[10]="Hello";

lcd_init();
while(1)
  {
   lcd_gotoxy(1,1);
   printf(lcd_putc,"%s",a);
   delay_ms(500);           
  } 
}

new error msg is "PCM: the CRG file is missing"
 

You need to have the 4 .crg files. They are the license files of CCS C Compiler. If you have the .crg files put them in CCS C installation folder. Also put lcd.c include after the lcd pin defines otherwise the code will not work.

you have used void manin() change it to void main()
 
Last edited:

new error msg after adding 4 .crg

"PCM: can not find DLL"

- - - Updated - - -

thnx i'm fix it :) , but when executing show this error

Code:
Error 128 "LCD.C" Line 42(1,6): A #DEVICE required before this line

?! :D
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top