View previous topic :: View next topic |
Author |
Message |
bignick270
Joined: 11 Sep 2008 Posts: 44
|
12x2 lcd screen with flexlcd.c or lcd.c? |
Posted: Wed Mar 18, 2009 1:08 pm |
|
|
Will the standard lcd driver and the flex lcd driver work right with a 12x2 lcd instead of the standard 16x2?
The controller for the lcd is based of a standard HD44780 controller. The lcd is made by crystalfontz and has a sunplus controller on it. The data sheet for the lcd (also includes the data sheet for the controller) is located here:
http://www.crystalfontz.com/products/1202a/datasheets/156/CFAH1202AYYHJP.pdf
I have been trying to get the dang lcd to work and i have had no success. I have tripled and quadruple checked my wiring connections. I have also checked it with multimeter and logic anaylzer.
With the flex lcd driver i changed the defines for the pins and i also commented out the part for the rw pin.
I looked at the data sheet for the sunplus controller and it seems the configuration bytes are correct.
I have the first line of the lcd showing up at black squares and nothing on the second. As i have read on here, the one line of squares indicates that it is not being properly initialized.
Also i am using a 4 bit data interface instead of a 8 bit interface.
My test program is the same test program that is located in the flexlcd.c driver post. I just modified it to work with the 16f818 that i had on hand (and yes i have the configuration settings right). |
|
|
bignick270
Joined: 11 Sep 2008 Posts: 44
|
|
Posted: Wed Mar 18, 2009 1:10 pm |
|
|
my defines are as followed
Code: |
#define LCD_DB4 PIN_B4 //PIN_D0
#define LCD_DB5 PIN_B5 //PIN_D1
#define LCD_DB6 PIN_B6 //PIN_D2
#define LCD_DB7 PIN_B7 //PIN_D3
#define LCD_E PIN_A0
#define LCD_RS PIN_A1
#define LCD_RW PIN_A2
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 18, 2009 1:34 pm |
|
|
1. Post your compiler version.
2. Do you guarantee that you are using pins DB4-DB7 on the LCD ?
3. Are you running the PIC and the LCD at 5 volts ? |
|
|
bignick270
Joined: 11 Sep 2008 Posts: 44
|
|
Posted: Wed Mar 18, 2009 1:37 pm |
|
|
4.082
and yes the data pins are connect right.
And yes the PIC and the LCD are running at 5 volts with a series resistor on the LED backlight pin as shown in the data sheet ( pin15). |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 18, 2009 1:48 pm |
|
|
Post the test program that you're using. This should be a short little
"Hello World" type of program that attempts make the LCD work.
Post the #include, #fuses, #use delay(), #include for the Flex_lcd.c,
and the main(). It should be compilable. (Don't post the code for
the flex lcd driver). |
|
|
bignick270
Joined: 11 Sep 2008 Posts: 44
|
|
Posted: Wed Mar 18, 2009 2:05 pm |
|
|
Code: |
#include <16F818.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPUT //No Power Up Timer
#FUSES NOMCLR //Master Clear pin used for I/O
#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
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#use delay(clock=8000000)
#include "C:\Documents and Settings\Nick\My Documents\New Folder\FLEXLCD.c"
//==========================
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
//nable_interrupts(GLOBAL);
setup_oscillator(OSC_8MHZ);
lcd_init(); // Always call this first.
lcd_putc("\fHello World\n");
lcd_putc("Line 2");
while(1);
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 18, 2009 2:16 pm |
|
|
1. You're using pins B6 and B7, which can be used by an ICD debugger.
Do you have a debugger or programmer attached to the board ?
If so, remove it.
2. I noticed you had global interrupts enabled. Have you run this test
program without that line ?
3. Have you ever made this board do anything, such as blink an LED ?
4. None of these lines need to be in the program. Try deleting them.
(I don't expect an improvement, but they are not needed).
Quote: | setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
//nable_interrupts(GLOBAL);
setup_oscillator(OSC_8MHZ); |
|
|
|
bignick270
Joined: 11 Sep 2008 Posts: 44
|
|
Posted: Wed Mar 18, 2009 2:25 pm |
|
|
global interrupts is commented out.
I have not done the led dance with this test code but I did yesterday with a copy of code i was working with when i was first trying to get the display to run using the standard lcd.c driver.
I have used the logic analyzer on the pins so i can see there is logic changes going to the lcd display.
I am not using a ICD debugger and I am not using a on board programmer. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
bignick270
Joined: 11 Sep 2008 Posts: 44
|
|
Posted: Wed Mar 18, 2009 2:35 pm |
|
|
Yes i have it right, my pin 15 is my back light pin for the led. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 18, 2009 2:44 pm |
|
|
I compared the 4-bit init commands between the Suncom controller and
the HD44780 and they are the same.
I ordered a few PICs earlier this the week. I'll receive a 16F819
tomorrow. I'd rather wait, and continue this tomorrow, after I test that
PIC with a 16x2 LCD.
Also, if you have a 16x2 LCD, you should test your board with that LCD. |
|
|
bignick270
Joined: 11 Sep 2008 Posts: 44
|
|
Posted: Wed Mar 18, 2009 2:49 pm |
|
|
Alright that sounds like an idea PCM programmer. The other lcd modules that i have are all graphic lcds and I do not have the circuitry set up for them. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 19, 2009 2:48 pm |
|
|
I got the 16F819 and I'm at the same place that you are. I can blink an
LED but it won't display anything on the LCD. I'll work it later in the day
and see if I can make it work. |
|
|
bignick270
Joined: 11 Sep 2008 Posts: 44
|
|
Posted: Thu Mar 19, 2009 2:52 pm |
|
|
well at least it is good to hear that i was not the only one with the problem. I tried to alter the flex lcd driver last night using different commands but I couldn't get anything to work. Keep me updated. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 19, 2009 4:18 pm |
|
|
I was able to make the 16F819 work with the LCD on a PicDem2-Plus
board. I tried to keep your pin numbers as much as possible. I couldn't
use your exact pins on PortA because the PicDem2-Plus is hard wired for
pins A1-A3. This was tested with vs. 4.089 and your version of 4.082.
Here's the test program that I used. It displays "Hello World" on the LCD.
Code: | #include <16F819.h>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=8000000)
// PicDem2-Plus pins
#define LCD_DB4 PIN_B4 // PIN_D0
#define LCD_DB5 PIN_B5 // PIN_D1
#define LCD_DB6 PIN_B6 // PIN_D2
#define LCD_DB7 PIN_B7 // PIN_D3
#define LCD_E PIN_A1 // Pin A1
#define LCD_RS PIN_A3 // Pin A3
#define LCD_RW PIN_A2 // Pin A2
#include "Flex_lcd.c"
//==========================
void main()
{
lcd_init();
lcd_putc("\fHello World\n");
while(1);
} |
In the Flex_lcd.c file, make sure this line is not commented out.
It should look like this:
Code: | #define USE_RW_PIN 1 |
Make sure that the contrast pin on your LCD is set at about 0.5 volts.
Measure it. |
|
|
|