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

Intermittent hanging of LCD.c

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



Joined: 26 May 2007
Posts: 14

View user's profile Send private message

Intermittent hanging of LCD.c
PostPosted: Sat May 26, 2007 5:14 pm     Reply with quote

I am working on a project where I am trying to connect a Varitronix LCD (digikey P/N 153-1078-ND) to a PIC18F4520. The problem I am having occurs in the LCD.c file at the while(bit_test(lcd_read_byte(),7)) line of code in the lcd_send_byte() function. Basically, sometimes the PIC will never exit the while loop or it will hang for a while then exit. This is my first LCD project so any suggestions would be greatly appreciated.

My compiler version is 3.241
_________________
Eric
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 26, 2007 9:29 pm     Reply with quote

1. Post the list of connections between your PIC pins and the LCD pins.

2. What's the Vdd voltage that you're using for the PIC and the LCD ?

3. What's the oscillator frequency of the PIC ?
peer9802



Joined: 26 May 2007
Posts: 14

View user's profile Send private message

PostPosted: Sun May 27, 2007 11:05 am     Reply with quote

PIC connections:
PIC D0 = LCD pin 6
PIC D1 = LCD pin 4
PIC D2 = LCD pin 5
PIC D4 = LCD pin 11
PIC D5 = LCD pin 12
PIC D6 = LCD pin 13
PIC D7 = LCD pin 14

Vdd = 5V for PIC and LCD
V0 connected with 10k pot to ground

Clock speed = 20 MHz.

Here is a little more info:
I am trying to create a circuit which counts an event and then displays the cycle number on the LCD panel and then sends the data via RS232 to a PC where I do some other things with the data. The circuit will work fine for a while (10 - 100 cycles) and then it will hang and I need to reset the microcontroller. I am pretty sure it is the while statement because I set an output high prior to the statement and then set it low after the statement is complete (e.g. output_high(PIN_A0); while() line; output_low(PIN_A0)). When the circuit is working properly I just see a 5V blip on my o-scope and when its not the pin stays at 5V.

Thanks for the help.
_________________
Eric
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 27, 2007 3:26 pm     Reply with quote

I looked at the Read timing specs in the LCD data sheet, and compared it
to the timing in the read_byte() routine in the LCD.c driver. It looks OK.
http://www.varitronix.com/Product/character/VL-FS-MDLS16265CSS-02.pdf

Here are two things you can try:

1. Change the "delay_cycles(1)" statements to a larger value.
You could change them to delay_cycles(5), or change them all
to delay_us(1). If there is a timing problem with your LCD, this
might fix it.

2. Try the Flex LCD driver from the Code Library. It has different
timing. See if it works. Edit the pin list at the top of the file to
match your PIC-to-LCD connections.
http://www.ccsinfo.com/forum/viewtopic.php?t=24661
Also, with that driver you can easily configure it to not test the
busy bit. Just comment out this line and re-compile.
Code:
         #define USE_RW_PIN   1

The driver will then use a fixed delay after sending a command
instead of reading the busy status.
peer9802



Joined: 26 May 2007
Posts: 14

View user's profile Send private message

PostPosted: Tue May 29, 2007 7:14 am     Reply with quote

Based on a previous post I had already changed the "delay_cycles(1)" to "delay_us(1)." This didn't help the problem.

The "as-is" flex LCD driver didn't work but commenting out the "#define USE_RW_PIN 1" line in the driver seemed to solve my problem. Thanks!

Assuming I had an LCD display that worked with LCD.c, are there any performance advantages to this driver?
_________________
Eric
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