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 support@ccsinfo.com

pic16f877 and LCD (black squares )

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mojsa2000



Joined: 18 May 2010
Posts: 78

View user's profile Send private message

pic16f877 and LCD (black squares )
PostPosted: Sat Jul 17, 2010 3:42 am     Reply with quote

Hi
I make a program with PIC16f877a. This program uses PORTD as LCD data port. When I simulate this program in Proteus
the eevrything is true but when I write the program to my chip and power it on, the lcd doesn't show anything.
I've checked the pcb and program more and more but there is no mistake or fault. I'm confused.
Also, to test the LCD, I made a simple program that should display a word as "hello" on lcd. But the lcd
doesn't show anything yet.
Only displays black squares on first line.
I've read all pages about this problem in forum. I've checked pins and connection. I use lcd driver in drivers folder and flex driver. I make different delay times before lcd_init and so on.

Whats your idea about it?

A part of program:
Code:

void main()
{
enable_interrupts(INT_AD);
enable_interrupts(INT_EXT);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
setup_adc_ports(AN0_AN1_AN3);
setup_adc(ADC_CLOCK_DIV_8);
setup_comparator(NC_NC_NC_NC);
ext_int_edge( H_TO_L );
setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);
setup_timer_0(RTCC_EXT_H_TO_L|RTCC_DIV_32);
set_timer0(0);
ds1307_init();
delay_ms(1000);
lcd_init();
// Set date for -> 15 July 2005 Tuesday
// Set time for -> 15:20:55
ds1307_set_date_time(15,7,10,6,0,0,0);
ds1307_get_date(day,month,year,dow);
ds1307_get_time(hour,min,sec);
Abdulla M.A.



Joined: 28 Mar 2010
Posts: 30
Location: Baghdad, Iraq

View user's profile Send private message Visit poster's website Yahoo Messenger

PostPosted: Sat Jul 17, 2010 4:16 am     Reply with quote

1- May be the problem was in the initialization of the LCD, there was no
enough time after set/clear "E" or "RS" to initialize the LCD.

2- Give an delay time after ---> lcd_init();

Abdulla
_________________
"A scientist can discover a new star, but he cannot make one. He would have to ask an engineer to do that."
"For an optimist the glass is half full, for a pessimist it's half empty, and for an engineer is twice bigger than necessary."
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Sat Jul 17, 2010 4:28 am     Reply with quote

You may want to try adjusting the contrast of the LCD. Put a trim potentiometer on the contrast pin of the LCD, across Vcc and Ground. Fiddle around with it until you get visible characters.

Rohit
mojsa2000



Joined: 18 May 2010
Posts: 78

View user's profile Send private message

PostPosted: Sat Jul 17, 2010 5:00 am     Reply with quote

Rohit de Sa wrote:
You may want to try adjusting the contrast of the LCD. Put a trim potentiometer on the contrast pin of the LCD, across Vcc and Ground. Fiddle around with it until you get visible characters.

Rohit


I've used a multi turn POT(5K ohm)
also I use a delay about 1s before lcd_init() command.
is it necessary to change the lcd library delay times?
thanks
mojsa2000



Joined: 18 May 2010
Posts: 78

View user's profile Send private message

Help.
PostPosted: Sat Jul 17, 2010 9:22 am     Reply with quote

I don't know that I should do now. I'm confused. Everything is correct. Pins, connections, Vcc (+5v), potentiometer but the LCD can't show a simple word.
I browsed the forum and I found that many users have had this problem.
Please help me. It is vital for me.
please help
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 17, 2010 11:12 am     Reply with quote

Well, it doesn't work, so therefore everything is not correct.
You need to find the problem.

First, use a much more simple program, like this:
Code:

#include <16F877.H>
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=20000000)

#include "lcd.c"
//=================================
void main()
{
lcd_init();

lcd_putc("\fHello World");

while(1);
}

I assume you're using the CCS lcd.c driver. (You didn't say which driver
you are using).

Set the contrast voltage on the LCD (using the 5K pot) to 0.4 volts.
That should be about correct.
mojsa2000



Joined: 18 May 2010
Posts: 78

View user's profile Send private message

PostPosted: Sat Jul 17, 2010 2:12 pm     Reply with quote

I did those you suggest. But the problem didn't solve. The version of my compiler is 4.093 and I've used lcd driver that is in "driver" folder and the driver that is in this forum as "flex_lcd".
I checked the connections and voltages again.
IC is PIC16F877A and crystal 4MHz.
The lcd is TS1620-1.
Please help me if you can.
MiniMe



Joined: 17 Nov 2009
Posts: 50

View user's profile Send private message

PostPosted: Sat Jul 17, 2010 2:30 pm     Reply with quote

Well If in your case char LCD shows blocks ... partly maybe, there is no initialization, that means your LCD did not get all information. And maybe contrast is little off. If you see blocks on screen after initialization lcd should show things you want ... that means contrast is OK.

Very important is to connect all the grounds together... if you wont there will be no data movement.


Re check or re solder you wires... often it helps.
mojsa2000



Joined: 18 May 2010
Posts: 78

View user's profile Send private message

PostPosted: Sat Jul 17, 2010 3:45 pm     Reply with quote

about my program:
I use portD to data sending. I connected RW pin to Ground.
When I'm programming the PIC, lcd doesn't connect to the board. Is it necessary to connect the lcd when I program the pic?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 17, 2010 4:08 pm     Reply with quote

Code:
I connected RW pin to Ground.

The lcd.c driver doesn't support doing this ! So, you were doing
something incorrect.

The flex_lcd.c driver does support it, but you must follow the instructions
for the driver, and comment out one of the #define statements.
mojsa2000



Joined: 18 May 2010
Posts: 78

View user's profile Send private message

PostPosted: Sat Jul 17, 2010 5:10 pm     Reply with quote

I connected the RW pin to PIN_D2 but the problem didnt solve.
mojsa2000



Joined: 18 May 2010
Posts: 78

View user's profile Send private message

PostPosted: Sat Jul 17, 2010 5:44 pm     Reply with quote

Hi
Thanks for your information. The problem solved. PCM was right.
I connected PIN_D2 to RW pin of lcd and problem cleared.
I love this forum.
Thanks
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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