View previous topic :: View next topic |
Author |
Message |
umka
Joined: 28 Aug 2007 Posts: 99 Location: New Zealand
|
LCD problem |
Posted: Mon Sep 10, 2007 4:44 pm |
|
|
i am having a problem with a 4x20 LCD.
here is the test code
Code: | #include <16F628a.H>
#fuses XT, NOWDT, NOPROTECT
#use delay(clock = 4000000)
#include <Flex_LCD420.c>
//===================================
void main()
{
// The lcd_init() function should always be called once,
// near the start of your program.
lcd_init();
printf(lcd_putc, "\f");
delay_ms(500);
while(1)
{
output_high(pin_a0);
delay_ms(100);
output_low(pin_a0);
// Test the clear screen and newline commands.
// Also test that we can write to all 4 lines.
printf(lcd_putc, "\fThis is the 1st line");
printf(lcd_putc, "\nNext is the 2nd line");
printf(lcd_putc, "\nThis is the 3rd line");
printf(lcd_putc, "\nFinally the 4th line");
delay_ms(3000);
printf(lcd_putc, "\f");
delay_ms(500);
}
} |
pins on pic16f628a are defined as below in the flex_lcd file
Code: | #define LCD_DB4 PIN_B0
#define LCD_DB5 PIN_B1
#define LCD_DB6 PIN_B2
#define LCD_DB7 PIN_B3
#define LCD_RS PIN_B4
#define LCD_RW PIN_B5
#define LCD_E PIN_B6 |
i have put the Flex_lcd420.c file in witht the other lib's is that the correct place for it?
i put the led in on pin a0 to see if it was working but it doesnt flash so i presume it is not cycling throught the code in the while(1) loop.
anyone know what is wrong? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 10, 2007 4:52 pm |
|
|
Quote: | #fuses XT, NOWDT, NOPROTECT |
Add NOLVP to the #fuses statement. It's essential. |
|
![](templates/subSilver/images/spacer.gif) |
umka
Joined: 28 Aug 2007 Posts: 99 Location: New Zealand
|
|
Posted: Tue Sep 11, 2007 12:44 am |
|
|
still no luck. i have just wired the lcd terminals to the pic terminals that corrispond in the flex file. anything else i may be doing wrong? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 11, 2007 12:53 am |
|
|
Quote: | I have just wired the lcd terminals to the pic terminals |
You must also connect power and ground, and the contrast voltage.
Use a trimpot to set the contrast voltage to 0.4 volts. The LCD data
sheet will tell you what pins to use for these. |
|
![](templates/subSilver/images/spacer.gif) |
umka
Joined: 28 Aug 2007 Posts: 99 Location: New Zealand
|
|
Posted: Tue Sep 11, 2007 1:19 am |
|
|
sorry i have already done this and still no luck. if i change the trim pot i get the contrast and all line are "active" but no text is being written. it is cycling throught the code though. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 11, 2007 1:22 am |
|
|
Post the manufacturer and part number of your LCD. |
|
![](templates/subSilver/images/spacer.gif) |
umka
Joined: 28 Aug 2007 Posts: 99 Location: New Zealand
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 11, 2007 11:45 am |
|
|
This page shows photos of the LCD.
http://www.sure-electronics.com/products/display/de-lm005.html
The data sheet shows that it's a normal 20x4 LCD. The flex driver
should work.
I suggest that you try the CCS driver: LCD420.c
It's in this directory:
Quote: | c:\Program Files\Picc\Drivers |
It's setup to use PortB. The pin list is slightly different than the list
in your post. I suggest that you change your board so it fits the CCS
driver, and then try it. |
|
![](templates/subSilver/images/spacer.gif) |
umka
Joined: 28 Aug 2007 Posts: 99 Location: New Zealand
|
|
Posted: Tue Sep 11, 2007 10:55 pm |
|
|
still no luck. might it be because it is a 16f628a chip?
when i connect the lcd to power, with all data wires disconnected and adjust the contrast it only makes line 2 and 4 fill with no change to line 1 and 3.
might there be a problem witht he lcd?? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 11, 2007 11:21 pm |
|
|
Post your compiler version. It's given at the top of the .LST file.
You can find the .LST file in your project directory. The version
number is a 4-digit number in this format: x.xxx
Post it and I'll check if there is a problem with your version. |
|
![](templates/subSilver/images/spacer.gif) |
umka
Joined: 28 Aug 2007 Posts: 99 Location: New Zealand
|
|
Posted: Wed Sep 12, 2007 12:24 am |
|
|
it is Version 3.249 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 12, 2007 1:22 am |
|
|
I installed vs. 3.249 and tested your program on a PicDem2-Plus board
with a CrystalFontz 20x4 LCD. I was able to make it work.
I had to do these things:
1. Add NOLVP to the #fuses shown in your program.
2. Remove the LCD connection to pin B2 on the PIC, and move it to
pin B7. Also change the #define statement for the LCD_DB6 pin
so it uses PIN_B7.
3. Unplug the ICD2 cable, to let the PIC program run.
The reason for not using Pin B2 is because on my PicDem2-Plus board,
there is a MAX232A chip which drives that pin. Pin B2 is the Rx pin for
the RS-232 port on the PIC.
The reason for unplugging the ICD2 cable, is because it uses pins B6 and
B7 to communicate with the PIC. The PIC program can't talk to the
LCD while the ICD2 is attached to the board. |
|
![](templates/subSilver/images/spacer.gif) |
|