Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with connecting LCD to PIC16876A (PORTB & PORTA)

Status
Not open for further replies.

Z80

Full Member level 1
Joined
Feb 20, 2004
Messages
96
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,257
Weird problem

I am having this very annoying problem.
I have a board with a PIC16F876A and everything works fine. Well, yesterday I mounted a LCD on it (manufacturer Jean, part ID 16201S). It is connected to PORTB and PORTA (it has 11 inputs). When I configure the appropriate pins from PORTA and PORTB as outputs, everything stops working. And everything means that the PIC seems to be dead. When I remove the lines that configure the ports from the source code, all is OK.
I have tested if the pins are short circuited and they aren't. The PIC is connected to the LCD module through 10 KOhms resistors. I am using 20MHz crystal.
I'm suspecting that the problem is (maybe?) a parasitic capacitance caused by one of the wires that connect the LCD and the PIC, it is passing near the crystal. I'm suspecting that 'cause the PIC resets when I close my hand to the crystal. Note that this wasn't happening before mounting the LCD!
I haven't been too careful with the ground circuit either, it has some loops (I am using a test board). Last, the main decopupling capacitors (470uF) may be too small for the power consumption of the LCD. I have used 100nF capacitors for each separate chip. By the way, there is an I2C memory on the board, and a low-pass active filter connected to the PWM output of the PIC.
Should putting bigger decoupling capacitors help? Or am I looking in the wrong place? Also, should I care for ground circuit loops? This hasn't caused me problems in digital circuitry untill now.
I have completely ran out of ideas, any help would be much appreciated. Thank you in advance.
 

Re: Weird problem

Hi,

Try use an external clock source... I had similar problem with PIC at 20 MHz. At lower frequency all was ok...

Cheers !
 

Re: Weird problem

Z80,

can you post your schematics and your code here so that somebody has a look at it?

What kind of display (standard 16 char 2 lines) have you connected?

How do you try to initialize your display?

best regards
 

Re: Weird problem

C-Man said:
Z80,

can you post your schematics and your code here so that somebody has a look at it?

best regards

TRISA2 = 0; // RB0 is reserved for external interrupt
// RA2, RB1 ... RB7 are the data lines for the LCD
TRISB1 = 0;
TRISB2 = 0;
...
TRISB7 = 0;
// RA3 ... RA5 are control inputs for the LCD (R/W, enable, and data/instruction)
TRISA3 = 0;
TRISA4 = 0;
TRISA5 = 0;

If I comment those lines everything works OK. Otherwise the PIC is DEAD. I will bring the rest of the code tomorrow, if it is necessary.

C-Man said:
What kind of display (standard 16 char 2 lines) have you connected?

It is a 2 llines, 16 chars display, part ID 16201S, you can find datasheet here **broken link removed**

C-Man said:
How do you try to initialize your display?

Well, as the datasheets says. But... how can I initialize it with a dead PIC? :) As I said, from the moment when I set the ports to the LCD as outputs (in order to configure it, among other things), the PIC seems to be dead. I can't blink a damn LED, that is.
 

Re: Weird problem

I would really like to see the initialisation code :)

Did you double check that your connected display does not have contact with a trace of reset or oscillator because i can not imagine a situation where connecting a display to the pic makes the whole thing stop working at all.

Connecting CS to RA4 is not a good idea as RA4 is an open collector pin and you will need a pullup which gives a H signal to CS of the display during power on. This might give a problem with display initialisation.

I would also suggest to use the display in 4 bit mode, this saves 4 portpins and the software does only get a tiny bit more complicated.

This are just my thoughts without haven seen your code.

hope this helps, best regards
 

Re: Weird problem

C-Man said:
I would really like to see the initialisation code :)

Did you double check that your connected display does not have contact with a trace of reset or oscillator because i can not imagine a situation where connecting a display to the pic makes the whole thing stop working at all.

Connecting CS to RA4 is not a good idea as RA4 is an open collector pin and you will need a pullup which gives a H signal to CS of the display during power on. This might give a problem with display initialisation.

I would also suggest to use the display in 4 bit mode, this saves 4 portpins and the software does only get a tiny bit more complicated.

This are just my thoughts without haven seen your code.

hope this helps, best regards

Yes, it does help a lot. In fact, I simply forgot that RA4 is open collector output! Imagine that. I will use another pin, I think that pin is connected to the "Enable" line, this should stop the LCD from being initialized correctly.
The 4-bit idea is also cool, I will do that as soon as I solve the other problems.
If the problems persist, I will bring schematics and the source code tomorrow.
Thank you again.
 

Re: Weird problem

Hi people

This is what I have done yesterday: replaced 10 KOhm resistors to LCD with 330 Ohm ones (not that this could cause the PIC to not function, but...), moved a control line for the LCD from RA4 (which I forgot that is open collector/(drain?)), mounted bigger main decoupling cap (2200u instead of 470u), put an 100nF cap close to the LCD, replaced (at someone's suggestion) the 20 MHz crystal with a 18.432 MHz one, and soldered a wire to ground to its capsule (well, that resetting when closing my hand made me paranoid) and tried another power supply. Results: now the PIC doesn't die when configuring the LCD ports, but something strange still happens: if I leave the power supply connected to the board, and removed from the outlet (wall powerplug to avoid confusions), and plug it in the outlet afterwards, all works. If I leave it in the outlet, and insert the power jack in the board afterwards, nothing works. What does this suggets? Power-up reset problems right? What do you recommend next?
 

Re: Weird problem

You should enable Brownout Detect and Powerup Timer to avoid these problems.

Do you have an RC network connected to the Reset Pin or is it just tied to +5V?

Also check the oscillator configuration (should be HS above 4 MHz) I always use 22pF capacitors on both Clkin and Clkout.

best regards
 

Re: Weird problem

C-Man said:
You should enable Brownout Detect and Powerup Timer to avoid these problems.

Nothing changes when activating BOR and PWRT!

C-Man said:
Do you have an RC network connected to the Reset Pin or is it just tied to +5V?

I have a 100nF cap connected from reset pin to GND, and a 10 KOhm resistor to Vcc. I thought about putting a bigger cap.

C-Man said:
Also check the oscillator configuration (should be HS above 4 MHz) I always use 22pF capacitors on both Clkin and Clkout.

I use 15 nF caps for OSCIN and OSCOUT, as the datasheets recommends.
 

Re: Weird problem

Do you mean 15pF (which should also be OK)?

Because 15nF is wayyyyy to big!

Please check this.

best regards
 

Re: Weird problem

C-Man said:
Do you mean 15pF (which should also be OK)?

Because 15nF is wayyyyy to big!

Please check this.

best regards

Yes, I meant 15 pF, sorry for the confusion.
 

Re: Weird problem

Hi people

Problem solved. It turned out that I kept LVP enabled at programming (don't ask me why), but didn't tie RB3 to ground. For some strange reason, the problem manifested itself only when configuring those pins as outputs (probably those wires induced a voltage high enough to activate LVP). But a anyway, with your help I also discovered some other problems.

Regards,
Z80
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top