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

LCD Problems

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








LCD Problems
PostPosted: Sun Feb 12, 2006 9:36 pm     Reply with quote

I just graduated from school and I'm working on projects to help advance my knowledge while I'm looking for a job. Currently I'm working on connecting an LCD to a PIC16F874, but I'm not having much luck. I've learned enough about the connections - I'm positive my wiring is correct. But what I'm having trouble with is getting the software to work. My clock is a 20 mhz oscillator, which might be a problem, but other than that I can't understand why this isn't working. My code is below:

Code:
#include <16F874.H>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include <stdlib.h>
#include <lcd.c>

main() {

  delay_ms(1000);
  lcd_init();
  delay_ms(1000);

  lcd_putc("\fDoes this work\n");
  //printf(lcd_putc, "Hello World.");
  delay_ms(1000);
}



I'm not exactly sure what the problem is, whenever I run this code the LCD just spits out like 5 or 6 characters (I'm not sure how many, I haven't counted them, but it's the same each time). But the characters themselves is basically a black box, only one dot is missing, so something like this:

.....
....
.....
.....

see how one dot was gone?? I don't know what the problem is. Do I need to manually change the enable pin and make it go from high to low? I can't see how that would be the case because I'm using this function....please help...

-Chris
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 12, 2006 9:51 pm     Reply with quote

Download the Microchip PicDem2-Plus manual here:
http://ww1.microchip.com/downloads/en/devicedoc/51275b.pdf
Go to page 20, and look at the LCD schematic in the upper left corner.
How is your circuit different from this one ?

Note that though they show trimpot R20, on the actual board it is not
installed. Only R5 and R6 are installed.
Guest








PostPosted: Sun Feb 12, 2006 10:18 pm     Reply with quote

According to the LCD.c file, these are what my pins are connected to:

Code:
// As defined in the following structure the pin connection is as follows:
//     B0  enable
//     B1  rs
//     B2  rw
//     B4  D4
//     B5  D5
//     B6  D6
//     B7  D7
//
//   LCD pins D0-D3 are not used and PIC B3 is not used.


Also, although you can use two resisters to do the job, I'm actually using a 10kohm POT. Not that it matters, both ways work.

Let me know if you have any other advice.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 12, 2006 10:32 pm     Reply with quote

Strip your program down to essentials. Also, you didn't post a
#fuses statement. I have added one.

Try this program:
Code:

#include <16F874.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)

#include <lcd.c>

void main()
{
lcd_init();

printf(lcd_putc, "Hello World");

while(1);
}
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