|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
LCD Problems |
Posted: Sun Feb 12, 2006 9:36 pm |
|
|
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
|
|
Posted: Sun Feb 12, 2006 9:51 pm |
|
|
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
|
|
Posted: Sun Feb 12, 2006 10:18 pm |
|
|
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
|
|
Posted: Sun Feb 12, 2006 10:32 pm |
|
|
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);
} |
|
|
|
|
|
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
|