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

New CCS user with LCD problem
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

New CCS user with LCD problem
PostPosted: Mon Oct 17, 2005 11:59 am     Reply with quote

Hello,

I'm trying to write to an LCD using a 16F877A but am having no luck. The LCD does work with a 16F84 using PIcBasic Pro. I've used the simple examples from the forum to try to troubleshoot my problem. Using the following code, the LED lights up in the first instance but doesn't for the second so I would guess that the program doesn't come out of lcd_init(). I've made no changes to lcd.c. Does anybody have any ideas?

Thanks....Harry

Code:
#include <16F877A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#include <lcd.c>

void main()
{

output_high(PIN_C0);
   delay_ms(500);
   output_low(PIN_C0);
   delay_ms(500);
   
lcd_init();

output_high(PIN_C0);
   delay_ms(500);
   output_low(PIN_C0);
   delay_ms(500);

printf(lcd_putc,"\fHello");

while(1);
}   
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 12:04 pm     Reply with quote

What board are you using ? Post the exact name.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Oct 17, 2005 12:10 pm     Reply with quote

Most likely your LCD is not connected the way the LCD.C driver file is written for. The init function makes a call that waits for the LCD to respond. If it doesn't, then it will hang.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 12:22 pm     Reply with quote

PCM Programmer: I've just got the chip and LCD breadboarded...no board, if that's what you mean.

Mark: I've connected the 4 bit data bus from the LCD (last 4 pins) to pins D4 to D7 (pins 27-30) on the 16F877A.

Thanks....Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 12:26 pm     Reply with quote

What about the other three pins, and power & ground, and contrast ?
Quote:
// 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
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 12:53 pm     Reply with quote

I think I've got it wired up properly because as I said I have it working perfectly on a 16F84 with PicBasic Pro. What I've done on the 16F877A is:

register select to D1
Enable to D0
I've tried R/W on both pin D2 and ground.
pin 3 on the LCD goes to a 10K pot.
pin 1 to Vdd (gnd)
pin 2 to Vss (5 volts)

Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 1:05 pm     Reply with quote

Quote:
I've tried R/W on both pin D2 and ground.

Don't connect R/W to ground. With the CCS driver it must go to the PIC.

Quote:
as I said I have it working perfectly on a 16F84 with PicBasic Pro.
Because you're using a different PIC and new breadboard, the
PBP experience doesn't really apply, or it applies only partially.

I suggest that you get the new breadboard working with PBP.
Then try it with CCS.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 1:42 pm     Reply with quote

I don't have any short term access to PBP...that's why I just bought the CCS compiler and programmer. A friend has PBP but he lives about 30 miles from me. I did a lot of soul searching before I settled on a C compiler...I hope I made the right decision.

I guess what you're saying is that if I've done all the things I've said I did it should work. Did I get that right? Smile

I've checked out the code in the init section because I'm quite sure it's hanging up in there but nothing jumps out at me, mainly because I really don't have a good feel for the language yet. Is there anything I could do with a cheap 10MHz scope that might tell me what's happening?

Thanks....Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 1:58 pm     Reply with quote

Check the contrast voltage on Pin 3 of the LCD. Set it for 0.4 volt.
Carefully check all LCD connections. Make sure you understand
the pin numbering scheme on the LCD.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 2:04 pm     Reply with quote

[quote="PCM programmer"]
Quote:
Don't connect R/W to ground. With the CCS driver it must go to the PIC.


I just checked on the R/W pin and it was still connected to ground. Embarassed When I moved it over to Pin D2 the program ran right through to the end but still nothing showed up on the LCD. I guess that's progress. Wink

Any other ideas?

Thanks....Harry
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Oct 17, 2005 2:17 pm     Reply with quote

[quote="Harry Mueller"]
PCM programmer wrote:
Quote:
Don't connect R/W to ground. With the CCS driver it must go to the PIC.


I just checked on the R/W pin and it was still connected to ground. Embarassed When I moved it over to Pin D2 the program ran right through to the end but still nothing showed up on the LCD. I guess that's progress. Wink

Any other ideas?

Thanks....Harry


You mean that you saw the LED blink twice?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 2:17 pm     Reply with quote

Check the contrast voltage on pin 3. Set it to 0.4 volts.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 2:18 pm     Reply with quote

PCM programmer wrote:
Check the contrast voltage on Pin 3 of the LCD. Set it for 0.4 volt.
Carefully check all LCD connections. Make sure you understand
the pin numbering scheme on the LCD.


I've done what you suggested...contrast voltage was at .7 volts....still nothing. I'm going to get away from this for a bit and come back in an hour or so and start over with a fresh mind....this one's gotten a little stale!

Thanks for the help....Harry
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 2:22 pm     Reply with quote

[quote="Mark"]
Quote:

You mean that you saw the LED blink twice?


Yes!! Then I moved the first group of 4 LED statements behind the print statement and the LED blinked twice again but nothing showed up on the LCD.

Harry
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Oct 17, 2005 4:35 pm     Reply with quote

Well, my little bit of respite didn't help and to make matters worse my wife needs my help in the kitchen. But before I go I've got to say that the LCD is wired up properly....I think. Laughing

LCD pin 1......gnd
LCD pin 2......5V
LCD pin 3......pot @ .4V
LCD pin 4......D1 (pin 20 on 877)
LCD pin 5......D2 (pin 21)
LCD pin 6......D0 (pin 19)
LCD pins 7-10....empty
LCD pin 11....D4 (pin 27)
LCD pin 12....D5 (pin 28)
LCD pin 13....D6 (pin 29)
LCD pin 14....D7 (pin 30)

The uC was brand new a couple of hours ago, but who knows.

Guess I'm stuck unless any kind soul out there has some insight into what I can try next.

Thanks....Harry
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 1, 2, 3  Next
Page 1 of 3

 
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