View previous topic :: View next topic |
Author |
Message |
doggitz
Joined: 04 Sep 2011 Posts: 9
|
LCD Driver |
Posted: Sun Sep 04, 2011 9:42 am |
|
|
A newbie needs some help. I am using an 18F4620 with a PCWH compiler and a PICKIT2 programmer. I am very new to C but have a reasonable amount of experience with BASIC. I have been using the WIZARD in the CCS IDE and find it very helpful for getting started. After compiling my program, I use the PICKIT2 software to import the hex file and program the chip. I have tried a few led flashing programs and it seems to work perfectly.
I can't get the lcd.c to work. My pin connections are:
Enable D5
RS D4
Data4 D0
Data5 D1
Data6 D2
Data7 D3
I am using the wizard to set the pins and when I look at the #define statements they are set correctly. I am using a 10MHz crystals and have set this, also in the wizard. As part of the program, I am flashing an LED, so I know my chip programming steps are working. I have used my BASIC compiler to test the board and the lcd, and it works properly.
Here is my program
Code: |
#include <lcdwiz3.h>
#define ENABLE_PIN D5
#define RS_PIN D4
#define Data4 D0
#define Data5 D1
#define Data6 D2
#define Data7 D3
#include <lcd.c>
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
//Example blinking LED program
while(true){
output_low(LED);
delay_ms(DELAY1);
output_high(LED);
delay_ms(DELAY2);
}
lcd_init();
lcd_putc("\f.Testing 1-2-3");
}
|
The include file is
Code: |
#include <18F4620.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES LP //Low power osc < 200 khz
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(clock=10000000)
#define LED PIN_C0
#define DELAY1 25
#define DELAY2 50
|
The screen displays either nothing, or blocks in all spaces. Help !!
I have spent about 10 hrs and can't get this to run.
Thanks
Doggitz |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9173 Location: Greensville,Ontario
|
|
Posted: Sun Sep 04, 2011 9:58 am |
|
|
While I don't use that PIC or lcd driver...
... the first thing is that you've got a fuse set for LP option(<200KHz) yet the #use delay(clock=10,000,000) //my commas
and you say you're using a 10MHz xtal.....
So I'd select the correct fuse for that xtal....
I use the flex_lcd driver with no problems...so perhaps maybe you haven't enabled/disabled the RW line or enable LCD control line ?? |
|
![](templates/subSilver/images/spacer.gif) |
doggitz
Joined: 04 Sep 2011 Posts: 9
|
LCD |
Posted: Sun Sep 04, 2011 10:44 am |
|
|
Thanks for the thought
Tried commenting out the LP line - no effect
I have also tried the flex_lcd driver and get the same result
I look at the comment section for the flex_lcd driver and find comments about grounding the RW line. I'm not sure whether that line on my board is grounded (I know that it is NOT connected to the chip) but will check it. As I mentioned, I tried a little test program using Proton Basic with the exact same set up on my test board, and the display works perfectly.
-D |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9173 Location: Greensville,Ontario
|
|
Posted: Sun Sep 04, 2011 12:17 pm |
|
|
Your LCD to PIC wiring is wrong...
According to the LCD.c driver..
// As defined in the following structure the pin connection is as follows:
// D0 enable
// D1 rs
// D2 rw
// D4 D4
// D5 D5
// D6 D6
// D7 D7
you've got..
Enable D5
RS D4
Data4 D0
Data5 D1
Data6 D2
Data7 D3
So..
you either have to rewire the connections to be compatible with the LCD.c driver
OR
recode the driver to conform to your pinout
OR
use the flex_lcd driver and configure it to be 'pin compatible' with how you want the connections to be made.This is what I do, far easier and simpler.
Any of the above options will work, it all depends on how you want to 'configure' the system. |
|
![](templates/subSilver/images/spacer.gif) |
doggitz
Joined: 04 Sep 2011 Posts: 9
|
|
Posted: Sun Sep 04, 2011 12:51 pm |
|
|
OK thanks --
I'll look at the flex driver and see how that works.
keep you posted |
|
![](templates/subSilver/images/spacer.gif) |
doggitz
Joined: 04 Sep 2011 Posts: 9
|
|
Posted: Mon Sep 05, 2011 9:17 am |
|
|
I have studied the flex_lcd driver documentation. It looks like the pin declarations are made in the driver - which I did. I also commented out the RW portion - which I am not using. I also included the stdio driver and made sure that my crystal was set to HS for a 10 MHZ crystal. No luck. All I get is a single (top) row of 5X8 pixel blocks. I also used an ohm meter to be sure all of the connections between the pic and the lcd were correct. any other suggestions? |
|
![](templates/subSilver/images/spacer.gif) |
|