View previous topic :: View next topic |
Author |
Message |
Salenko
Joined: 08 Sep 2008 Posts: 84
|
lcd_putc() works only when I touch the PICmicro |
Posted: Thu Aug 13, 2009 12:24 pm |
|
|
everybody Hi,
I'm facing a very weird behaviour of my microcontroller
my PIC 16F877A PICmicro can't execute the LCD control functions (init_lcd() and lcd_putc) without touching its case with my finger or touching the Ground with my finger or a metallic object.
I tested the PIC with various codes including features like RB interruptions , timers interruptions , CCP modules and it worked well.
the PIC is in a card (stepper motor control) and connected to and LCD through the 7 known pins :
compiler version : PCW 4.057
in the code, I used the flex_lcd driver
Code: |
#include <16F877A.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20000000)
#use rs232 (baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,ERRORS,bits=8)
#include "flex_lcd.c"
void main()
{
lcd_init();
delay_ms(1000);
lcd_putc("READY...\n");
while(1)
{}
}
|
is there any solution to make the PIC running without touching it ?
here is a schematic and a photo:
your help will be much appreciated.
thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 13, 2009 12:38 pm |
|
|
Put a 10K pull-up on the MCLR pin. (Or use 47K if you're using the
CCS ICD-U40).
The MCLR pull-up resistor is important. Put it in all your designs with the 16F877A. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1909
|
|
Posted: Thu Aug 13, 2009 12:57 pm |
|
|
If the MCLR pullup doesn't work, there may be a bad connection between your PIC and the LCD. The LCD driver routine features a wait - there's a while (pin low) or something like that which will cause the routine to appear to stall while the PIC waits for the proper condition. |
|
|
Salenko
Joined: 08 Sep 2008 Posts: 84
|
|
Posted: Thu Aug 13, 2009 1:08 pm |
|
|
PCM programmer wrote: | Put a 10K pull-up on the MCLR pin. (Or use 47K if you're using the
CCS ICD-U40).
The MCLR pull-up resistor is important. Put it in all your designs with the 16F877A. |
thank you PCM for your quick answer,
I already have a MCLR pull-up in the card, here is the schematic of my RESET circuit, I found it somewhere in internet and I think it is recommended by Microchip (if I'm not wrong).
is there a problem with it ?
another thing to add : I use a 16F877 as a spare PIC of the card.
Last edited by Salenko on Thu Aug 13, 2009 1:41 pm; edited 3 times in total |
|
|
Salenko
Joined: 08 Sep 2008 Posts: 84
|
|
Posted: Thu Aug 13, 2009 1:16 pm |
|
|
newguy wrote: | If the MCLR pullup doesn't work, there may be a bad connection between your PIC and the LCD. The LCD driver routine features a wait - there's a while (pin low) or something like that which will cause the routine to appear to stall while the PIC waits for the proper condition. |
thank you newguy for you help,
I'll verify again the PIC-LCD connections |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu Aug 13, 2009 1:27 pm |
|
|
ive been having similar problems...
sugestions on how to control such erratic behavior can be found on most of the threads ive started...
check them out.. some of the guys here posted some pretty good advice
im using the same pic as you are...
gabriel. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Salenko
Joined: 08 Sep 2008 Posts: 84
|
|
Posted: Thu Aug 13, 2009 1:35 pm |
|
|
Gabriel wrote: | ive been having similar problems...
sugestions on how to control such erratic behavior can be found on most of the threads ive started...
check them out.. some of the guys here posted some pretty good advice
im using the same pic as you are...
gabriel. |
Thank you Gabriel, I'll check them . |
|
|
Guest
|
|
Posted: Fri Aug 14, 2009 2:21 pm |
|
|
I had almost the same problem...
in my case the LCD was init. too soon (when I touch the board pic was somehow reseted and send the init command again so the LCD was init properly). It was solved by delay_ms(100) before lcd_init(); ... its the time LCD need after power up (its in the lcd datasheet). |
|
|
|