CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with Interfacing PIC 16F877A with LCD

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sharat68



Joined: 28 Oct 2010
Posts: 4

View user's profile Send private message

Problem with Interfacing PIC 16F877A with LCD
PostPosted: Thu Oct 28, 2010 4:36 pm     Reply with quote

Hi,

I'm trying to display text onto an LCD HD44780 using the PIC 16F877A. I am using the flex_driver given in this forum. I can see the blocks on the LCD and I can adjust the contrast, but I can't get it to display characters or anything on the LCD. Also, I am using PIC C Compiler and MPLAB. Can someone help me?

My PIN Connections:
Code:

DB7 - PIN_B7
DB6 - PIN_B6
DB5 - PIN_B5
DB4 - PIN_B4
RS - PIN_B3
RW - PIN_B2
E - PIN_B1

The external clock I am using is the FOX F1100E, 20 MHz.

The test code:
Code:

#include <16F877A.h>
#include "lcd_16x2.c"

#FUSES NOWDT      //No Watch Dog Timer
#FUSES HS         //Highspeed Osc > 4mhz
#FUSES PUT        //Power Up Timer
#FUSES NOPROTECT  //Code not protected from reading
#FUSES NODEBUG    //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP      //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD      //No EE protection

#use delay(clock = 20000000) // Sets crystal oscillator at 20 megahertz

   
//==========================
void main()
{

lcd_init();  // Always call this first.
lcd_putc("\fHello World");

while (TRUE) {
     
}
}



The driver code:
Code:

// lcd_16x2.c

// These pins are for the Microchip PicDem2-Plus board,
// which is what I used to test the driver.  Change these
// pins to fit your own board.

#define LCD_DB4   PIN_B4
#define LCD_DB5   PIN_B5
#define LCD_DB6   PIN_B6
#define LCD_DB7   PIN_B7

#define LCD_E     PIN_B1
#define LCD_RS    PIN_B3
#define LCD_RW    PIN_B2

Flex_lcd driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=24661
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 28, 2010 4:48 pm     Reply with quote

The most likely problems will be:

1. PIC not running. Check this by making an LED blinking program.
See it that works.

2. Incorrect connections between PIC and LCD. Crossed wires, or
wrong pins used, or broken wires, or solder shorts.

3. Using pins B6 and B7 while still having the ICD connected to the board.
Those two pins are used by ICD debuggers and programmers.
Either choose two other pins, or disconnect the ICD from the board.
Make sure you program the board in "Release" mode, and not in "Debug"
mode when you do this. It's easier to just use two other pins than B6 and B7.

4. Other external circuits are attached to the LCD pins, which prevents
the PIC from properly controlling the LCD.
sharat68



Joined: 28 Oct 2010
Posts: 4

View user's profile Send private message

PostPosted: Thu Oct 28, 2010 6:03 pm     Reply with quote

The PIC is working because I tested it with the LED blinking program and it worked. I'm sure I connected everything correctly and I even switched the B6 and B7 pins to port D. It still doesn't work, I guess I'll try resoldering my LCD.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group