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 CCS Technical Support

LCD Problem
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 25, 2007 11:34 am     Reply with quote

A 16x1 LCD is not simple. It has a break in the memory map in the
middle of the LCD. It's like an 8x2 LCD, except the bottom row is placed
on the right side. It requires a special driver. But even so, you should
still see some text displayed in the first 8 posititions on the LCD.

But you're still getting black squares. The usual reason for this is
because the LCD is not being initialized, or the contrast voltage is
set to an incorrect value. (It should normally be between 0v and .5v)
Measure the contrast voltage with a voltmeter. Is is correct ?


Here are some possible reasons for the LCD not being initialized:

1. The PIC is not running. Test this by making a small program
to blink an LED. See if it works.

2. The connections to the LCD are not correct. Make sure you're using
the upper 4 bits of the LCD for the data bus (DB4-DB7). Don't use
the lower four bits.

3. Are you running the PIC at 3 volts ? For a 5v LCD, you need to
run the PIC at 5v.

You said that you tried the Flex LCD driver. Post the #define statements
that you used, to declare the LCD pins.
faizanbrohi



Joined: 20 Sep 2006
Posts: 19

View user's profile Send private message

PostPosted: Sun Apr 29, 2007 12:44 pm     Reply with quote

Hello again , i have tried the Normal LCD.c driver from CCS with a PIC Trainer and the program does not work . However some code that was with the trainer worked quite well. So there is some problem with the driver , do you have to ground the DO-D3 pins ? . the trainer has grounded this in 4 bit mode , i want to create my own driver so i should see the datasheet of the Controller .
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 29, 2007 1:03 pm     Reply with quote

Post a link to website of the "PIC trainer" board.
faizanbrohi



Joined: 20 Sep 2006
Posts: 19

View user's profile Send private message

PostPosted: Sun Apr 29, 2007 9:19 pm     Reply with quote

the trainer is http://www.mikroe.com/en/tools/easypic4/ ,
EasyPIC4
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 29, 2007 9:50 pm     Reply with quote

There's a driver for that board in the CCS Code Library:
http://www.ccsinfo.com/forum/viewtopic.php?p=74125
Try it.

-----------
Note the comment near the top of that post, where it says:
Quote:
Note: rw permanently connected to gnd

So if you want to try the Flex driver with that board, you
need to follow the instructions in the Flex driver post, where
it says to comment out the #define statement that enables
use of the RW pin.
faizanbrohi



Joined: 20 Sep 2006
Posts: 19

View user's profile Send private message

PostPosted: Sat May 05, 2007 3:14 pm     Reply with quote

I have made a PCB for it now , and still not working i have modified the code to use pins A2-> RS , A3 -> EN , A4-D4 ,A5-D5 , A6-D6 , A7-D7 in the flex_lcd.c and now i also have a different 16x2 LCD with a ST7066U Controller , it has white back light. Still not working , something wrong with the IC or the code .

the pin definitions in the main program are for something else . they are for adc inputs

Code:

#include <16F628.h>

#FUSES NOWDT                    //No Watch Dog Timer
//#FUSES XT                       //Crystal osc <= 4mhz
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT                 //Reset when brownout detected
#FUSES NOMCLR                     //Master Clear pin enabled
#FUSES NOLVP                    //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOCPD    //No EE protection
#FUSES INTRC_IO
#FUSES NOLVP

#use delay(clock=4000000)
//#use rs232(baud=9600,parity=N,xmit=PIN_A3,rcv=PIN_A2,bits=8)
#include <flex_lcd.c>

#define D0 PIN_B0
#define D1 PIN_B1
#define D2 PIN_B2
#define D3 PIN_B3
#define D4 PIN_B4
#define D5 PIN_B5
#define D6 PIN_B6
#define D7 PIN_B7

void main()
{
PORT_B_PULLUPS(TRUE);
lcd_init();
lcd_putc("\fHello World...");

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 05, 2007 5:56 pm     Reply with quote

Quote:
A5-D5

Look in the 16F628 data sheet, in the section on Port A. There is a chart
that shows the possible functions for each i/o pin. Pin A5 is input-only.
You can't use it with the Flex LCD driver. Choose another pin.

Quote:
A4-D4

Look in the same section in the data sheet. Pin A4 is "open drain".
It can only pull-down. You need to add a 4.7k pull-up resistor to
this pin, if you use it with the Flex LCD driver.


Quote:
void main()
{
PORT_B_PULLUPS(TRUE);
lcd_init();
lcd_putc("\fHello World...");

while(1);
}

Also, it's best to add a while(1) statement at the end of your program,
as shown above in bold. The compiler puts a hidden SLEEP instruction
at the end of main(), and it will execute that instruction if you leave out
the while(1) statement. In this program, it probably doesn't affect
anything if you let it go to Sleep, but if you were sending characters to
the hardware UART, you would lose the last two characters. The PIC
would go to sleep before they were sent.
faizanbrohi



Joined: 20 Sep 2006
Posts: 19

View user's profile Send private message

PostPosted: Sat May 05, 2007 10:25 pm     Reply with quote

Hello , PCM Programmer , thanks for correcting me out , now it is working like a gem , changed pin to A1 and A0. Thanks a lot . i learned quite a lot about LCD's and PIC in the process . Now my job is to interface a ADC and see it's output on the LCD.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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