View previous topic :: View next topic |
Author |
Message |
peer9802
Joined: 26 May 2007 Posts: 14
|
Intermittent hanging of LCD.c |
Posted: Sat May 26, 2007 5:14 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat May 26, 2007 9:29 pm |
|
|
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 ? |
|
![](templates/subSilver/images/spacer.gif) |
peer9802
Joined: 26 May 2007 Posts: 14
|
|
Posted: Sun May 27, 2007 11:05 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun May 27, 2007 3:26 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
peer9802
Joined: 26 May 2007 Posts: 14
|
|
Posted: Tue May 29, 2007 7:14 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|