View previous topic :: View next topic |
Author |
Message |
Ares Guest
|
Problems with LCD driver |
Posted: Wed May 12, 2004 4:41 pm |
|
|
I have this code in a test program,but it doesn't work,leds don't shine.Port B is configured in the "LCD.c" archive as output for the LCD,but LCD it is not conected because i haven't any.Could it be that the problem?."LCD.c" arhive is the one on the original CCS PIC C Compiler progam,any change was made.
Thank you for your help.
#include <16F877.h>
#use delay(clock=4194304)
#fuses HS, NOWDT, NOPROTECT, NOPUT, NOBROWNOUT, NOLVP
#byte port_c=7
#define led1 PIN_C2
#define led2 PIN_C3
#include <lcd.c>
void main()
{
lcd_init();
set_tris_c(0x00);
port_c=0;
lcd_putc("Look this leds");
do
{
output_high(led1);
output_low(led2);
delay_ms(3000);
output_low(led1);
output_high(led2);
delay_ms(3000);
}while(true);
} |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Wed May 12, 2004 5:22 pm |
|
|
When you debug the code, does it get passed lcd_init()? What happend when you comment that line? |
|
|
Ares Guest
|
|
Posted: Thu May 13, 2004 8:28 am |
|
|
Haplo wrote: | When you debug the code, does it get passed lcd_init()? What happend when you comment that line? |
If I comment this lines:
lcd_init();
lcd_putc("whatever");
the rest of the program works well,that is,LEDs shine.I supose that if i had the LCD conected,program would work properly.The problem is that I can't find why it doesn't work without it.Any signal is sent from the LCD to the PIC ,at least I don't see anything in the "LCD.c" program,so I don't know if it really will work when It will be connected.
Thank you again for your help. |
|
|
C-H Wu Guest
|
the 'while loop' in lcd.c |
Posted: Thu May 13, 2004 9:07 am |
|
|
All your problems comes from the following line in lcd_send_byte() of CCS's driver, LCD.C:
while ( bit_test(lcd_read_byte(),7) );
if your LCD is not connected, then you will end up hanging in the while loop. I modified it with a timeout break like this
while ( bit_test(lcd_read_byte(),7) )
{
delay_us ( 5 );
if ( --i == 0 )
{
lcd_fail = TRUE;
break;
}
}
such that I can live with, or without, the LCD, or, with a dead LCD.
best wishes |
|
|
djpark
Joined: 02 Mar 2004 Posts: 49
|
Re: Problems with LCD driver |
Posted: Thu May 13, 2004 11:30 am |
|
|
Ares wrote: | I have this code in a test program,but it doesn't work,leds don't shine.Port B is configured in the "LCD.c" archive as output for the LCD,but LCD it is not conected because i haven't any.Could it be that the problem?."LCD.c" arhive is the one on the original CCS PIC C Compiler progam,any change was made.
|
"C-H Wu" has pointed out the correct hanging problem with stock LCD driver without a real LCD. Like him, I, too, use similar 2sec timeout routine in the status return function.
I also added a 4.7K register to the LCD panel bit7 to ground which will pull the status low if the port is read back, so that my LCD routine can read the pin status before init or write and if it is high (pulled up by 100k on PIC side), I consider the LCD is not connected. When it is connected back (status is low), I do lcd_init() again before further write.
It works like a magic. You can pull out and plug back the LCD panel and watch the LCD screen pop up correctly again.
-- dj |
|
|
Ares Guest
|
Thanks |
Posted: Thu May 13, 2004 4:15 pm |
|
|
Thank you,both of you for your help.I really feel more calmed now I know wich the problem was.I hope it will work with the LCD....hehehe.
Best wishes |
|
|
Guest
|
|
Posted: Thu May 13, 2004 5:09 pm |
|
|
try sticking in the following
printf(lcd_putc,"whatever"); |
|
|
RatFink
Joined: 01 May 2004 Posts: 49
|
|
Posted: Fri May 14, 2004 12:32 am |
|
|
I also have trouble with this driver using it with a crystalfontz LCD. I don't understand why they would make it use the Port B knowing that it cause problem with the ICD. |
|
|
MGP
Joined: 11 Sep 2003 Posts: 57
|
|
Posted: Fri May 14, 2004 7:31 pm |
|
|
RatFink wrote: | I also have trouble with this driver using it with a crystalfontz LCD. I don't understand why they would make it use the Port B knowing that it cause problem with the ICD. |
Because it's an older driver that's been around long before the ICD and on-chip debugging existed.
Most everyone that's been using CCS C for a while and uses the LCD driver library has changed it to fit their own requirements or written their own (that's what I did). |
|
|
RatFink
Joined: 01 May 2004 Posts: 49
|
|
Posted: Fri May 14, 2004 7:37 pm |
|
|
MGP wrote: | RatFink wrote: | I also have trouble with this driver using it with a crystalfontz LCD. I don't understand why they would make it use the Port B knowing that it cause problem with the ICD. |
Because it's an older driver that's been around long before the ICD and on-chip debugging existed.
Most everyone that's been using CCS C for a while and uses the LCD driver library has changed it to fit their own requirements or written their own (that's what I did). |
Is there someplace I could find one of these drivers. I know very little C language, my schooling is in Electronics but I've managed to get all my code to work except for the LCD. |
|
|
Mc
Joined: 07 May 2004 Posts: 11
|
|
|
Guest
|
|
Posted: Sat May 15, 2004 4:49 pm |
|
|
if your using the icd development board heres the reason why it does't work.
*********************************************************
Brian,
The pins 39 and 40 are not connected on the board other than to the ICSP socket since these pins need to be isolated during in-circuit programming.
Circuitry on these pins can cause corruption of the programming bitstream and clock. It may be possible to use the CCS complier's LCD functions with another port, however we are not familiar with the LCD section of the CCS compiler.
Best Regards,
UK Techhelp
INTERNET ACCESS
World Wide Web address -http://www.microchip.com/
FTP address - ftp://ftp.microchip.com/
*************************************************************
i have some source code which use port D, you can download it here:
(i didn't write them, but have used them and they work fine)
http://home.t-online.de/home/Matthias.Stehr/hoehe.htm |
|
|
RatFink
Joined: 01 May 2004 Posts: 49
|
|
Posted: Sat May 15, 2004 7:57 pm |
|
|
I tried that one and couldn't make it work, but I did find one here that worked real easy for me (Though I would rather not have the control bits on port A) I posted it in the code library because out of all of them I've tried, this one just worked. |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Tue Jun 29, 2004 2:44 pm |
|
|
I used C-H Hu and Djpark's method modified ares's program, however, I did not got the lcd display characters, but the rb7 led turns on. what is wrong with my code. my hardware is 26f877a, lcd connected to portb and every connection comes from the easy2 board, I did not change anything? advice please, and I also post the testing file provided by ares at "2X16 LCD on pic16f877a portb" post.
Thanks
[/code] |
|
|
E YILMAZ Guest
|
for modification... |
Posted: Sat Jun 04, 2005 11:19 am |
|
|
Thank you C-H Hu! |
|
|
|