Searching \ for '[PIC] Strange PIC-behaviour, MCLR-pin is the culpr' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/microchip/devices.htm?key=pic
Search entire site for: 'Strange PIC-behaviour, MCLR-pin is the culpr'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Strange PIC-behaviour, MCLR-pin is the culpr'
2009\04\08@141940 by Rikard Bosnjakovic

flavicon
face
Up til yesterday I have been working on an LCD-project on my
breadboard. I got everything to work perfectly so I decided to move
the circuit to a "real" board (veroboard) instead of the breadboard.

I soldered everything, checked solder for shorts and then plugged the
PIC (16F628A) and LCD onto the board. Turned on the power, got
jibberish text on LCD. Re-checked the datalines, E, RS and RW.
Everything was perfect, no shorts or anything. Doublechecked the
PIC-connections, no problems there either.

Got a bit puzzled while staring at the jibberish on the display.
Fetched my DMM to see if the MCLR-pin was at an okay voltage (Vcc -
R10k - pin). As soon as I touched the pin, the LCD got the expected
text and the board was working as expected.

Cycled the power, got jibberish again. Touched MCLR-pin with a needle
that wasn't connected to anything but my fingers, and the text showed
up again. Cycled power once more, got jibberish. Went to do something
else for 10 minutes, got back and still saw jibberish. Touched the
pin, voila - all working again.

When powered off, I use DMM on the pin and turn on the power.
Jibberish text but 5V on MCLR. I lift the probe and touch the pin
again, circuit works.Obviously the PIC is in some reset loop-state
until something touches the MCLR.

Can anyone explain what's going on? I haven't got the faintest idea.


--
- Rikard - http://bos.hack.org/cv/

2009\04\08@143500 by Vitaliy

flavicon
face
Rikard Bosnjakovic wrote:
{Quote hidden}

Can you provide relevant parts of the schematic? Do you have MCLR connected
to +5V through a resistor?

Try touching the pin with a dielectric object (like the tip of a plastic
pencil), to check for cold solder joints.

Vitaliy

2009\04\08@144641 by Philip Pemberton

face
flavicon
face
Rikard Bosnjakovic wrote:
> Can anyone explain what's going on? I haven't got the faintest idea.

Have you got anything connected to MCLR? It should be wired to Vcc via a 10k
resistor, and the datasheets for most PICs state that the internal reset
generator will not work correctly without that resistor.

Failing that, I'd get a storage oscilloscope, wire it to Vcc, and see how long
it's taking for Vcc to come up (if it's sitting at an indeterminate level for
too long, that could potentially cause problems with the reset logic in the PIC).

--
Phil.
spam_OUTpiclistTakeThisOuTspamphilpem.me.uk
http://www.philpem.me.uk/

2009\04\08@152437 by Isaac Marino Bavaresco

flavicon
face
Rikard Bosnjakovic escreveu:
{Quote hidden}

Why don't you just disable external MCLR? This way you gain one input
pin and don't need to worry about reset (the PIC has a good internal
reset circuitry).

Turn on the power-up timer also, so if your power supply is slow to
stabilize the PIC will wait a little more before getting out of reset
before trying to run.

Remember to wait 15 ms after the power supply stabilizes before
initializing the LCD (the 72ms power-up timer may not be enough if the
power ramps up too slowly).

Regards,

Isaac

__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/

2009\04\08@154101 by Barry Gershenfeld

picon face
>
> When powered off, I use DMM on the pin and turn on the power.
> Jibberish text but 5V on MCLR. I lift the probe and touch the pin
> again, circuit works.Obviously the PIC is in some reset loop-state
> until something touches the MCLR.
>
> Can anyone explain what's going on? I haven't got the faintest idea.
> --
> - Rikard - http://bos.hack.org/cv/
>

Generally speaking, MCLR should be at 0 V when the power comes up, and then
go to 5V afterward, thus performing a reset to an already-running chip.
Maybe this is done internally so you only need the resistor (maybe that's
why this hasn't been mentioned).  The other behavior makes me suspect your
MCLR isn't connected to anything--it should be.

Also, be sure the LCD has time to get running before the PIC throws data at
it.

2009\04\08@155725 by Picbits Sales

flavicon
face
This might sound a bit obvious but you do have adequate decoupling on your
power pins as close to the PIC as possible ?

What you are describing sounds similar to problems I had when I had a duff
bypass capacitor - very random happenings were - well happening lol.

Dom
{Original Message removed}

2009\04\08@170533 by Wouter van Ooijen

face picon face
> Generally speaking, MCLR should be at 0 V when the power comes up, and then
> go to 5V afterward, thus performing a reset to an already-running chip.

In the scenario you describe the PIC is powered up *in reset state* and
then is released to run. No reset on an already-running chip.

--

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu

2009\04\08@201023 by Jinx

face picon face
Try adding 0.01 - 0.1 uF from MCLR to 0V. The breadboard may
have some slight capacitance that circuit board doesn't. And a delay
of perhaps 50ms before initialising the LCD

2009\04\08@215307 by Xiaofan Chen

face picon face
On Thu, Apr 9, 2009 at 8:10 AM, Jinx <.....joecolquittKILLspamspam@spam@clear.net.nz> wrote:
> Try adding 0.01 - 0.1 uF from MCLR to 0V. The breadboard may
> have some slight capacitance that circuit board doesn't. And a delay
> of perhaps 50ms before initialising the LCD

Just take note that some programmers (eg: PICKit 2) might have problem
with 0.1uF tied to MCLR due to limit Vpp driving capability. So it is
recommended to use 0.01uF instead.


Xiaofan

2009\04\09@041457 by Rikard Bosnjakovic

picon face
Thanks everyone for the replies, I have now found a solution so I'll
answer all questions here.

> Do you have a resistor to MCLR?

1. Yes, I had a 10k-resistor to MCLR. I wrote about it in the OP but I
see now it was very vague described.

> Do you have decoupling caps?

2. No, I had none (shame on me!) but I didn't on the breadboard
either. Temporarily added one (it's a real pain to add decouplers when
using veroboard and Vcc/GND-pins are on opposite sides on the IC).

> Why do you use MCLR? Disable it and save a pin.

3. I have always used MCLR since I have read a lot of problems that
might arise when not using it: programming could lock me out from the
chip, etc, so I've always used it to be on the safe side. Since the
project is mature I don't need an extra pin either.

> Touch the pin with a dielectric to check cold soldering.

4. Did this. Nothing happened when I touched with plastic.


So I investigated a bit further to see why I had missed. I tried to
unhook the Wisp648 from the breadboard, and this way the breadboard
version behaves the same as the PCB-version. Putting back the
MCLR-cable from the Wisp and everything worked fine.

After this I disabled MCLR to see if that helped. It did not (with or
without decouplers). Therefore I read more about the power up-timer in
the datasheet and enabled it after suggested here.

Voila! That timer really did its job - everything works now (with or
without MCLR). Thanks for suggesting it.

However, I'm still pretty curious to find out why the original problem
appeared. I have always used MCLR for my projects, never had any
problems. Never been using 16F628a before, though. Maybe that chip
requires special attention, I do not know. But what I do know is that
I've always used the same PSU for my breadboard projects, so the "slow
powerup" should have been visible earlier.

Unfortunately I haven't got a scope, and cannot afford one, so I can't
have a look of what's really happening with the Vdd/MCLR-pins. In the
future, all my 628a:s will have PWRT enabled.


--
- Rikard - http://bos.hack.org/cv/

2009\04\09@044851 by Tamas Rudnai

face picon face
On Thu, Apr 9, 2009 at 9:14 AM, Rikard Bosnjakovic <
rikard.bosnjakovicspamKILLspamgmail.com> wrote:

> 2. No, I had none (shame on me!) but I didn't on the breadboard
> either. Temporarily added one (it's a real pain to add decouplers when
> using veroboard and Vcc/GND-pins are on opposite sides on the IC).
>

Which does not mean that you do not need it - EMI == Evil therefore you have
no idea when and where is that coming from, but you can make precautions to
void it. You can do a trick, to use a DIL socker and put the capacitor
underneath the socket, or use an smd on the other side. However, I think if
you just place the capacitor near to the Vdd pin and route the Vss there is
just fine.

Tamas
--
http://www.mcuhobby.com

2009\04\09@071904 by Philip Pemberton

face
flavicon
face
Rikard Bosnjakovic wrote:
> 2. No, I had none (shame on me!) but I didn't on the breadboard
> either. Temporarily added one (it's a real pain to add decouplers when
> using veroboard and Vcc/GND-pins are on opposite sides on the IC).

Get yourself a bag of 0.1uF, 0805 or 1206-package SMT ceramic capacitors.
These are great for adjacent and opposite power pins (which is usually the
case on PICs -- the 40pin chips usually have power on pins N and N+1, the
18-pins are usually pins 5 and 14).

Very handy for the inevitable "Oh $CURSE! I forgot to put the decouplers on
the PCB!" situations. You've already added the decouplers to PCB V1.1, but you
still have a stack of V1.0 PCBs that you really don't want to scrap...

> 3. I have always used MCLR since I have read a lot of problems that
> might arise when not using it: programming could lock me out from the
> chip, etc, so I've always used it to be on the safe side. Since the
> project is mature I don't need an extra pin either.

The problem with MCLR being turned off is that you need a programmer that can
drive MCLR to +12V before it brings up Vcc -- that's the only situation that's
near-absolutely guaranteed to make a PIC power up in program mode, even when
MCLR is disabled.

[PWRTE]
> Voila! That timer really did its job - everything works now (with or
> without MCLR). Thanks for suggesting it.

Your code is trying to initialise the LCD before the display controller has
finished powering up.

From experience, most Hitachi HD44780 and Samsung KS0066 based modules need a
good 15-20 milliseconds between Vcc coming up enough for the PIC to boot, and
the display being ready to accept a command. Some LCD modules built by
manufacturers who really should have read the datasheets can take up to 80 or
90 milliseconds to boot, though these are (thankfully) rare.

What PWRTE is doing is making the PIC spin and do nothing until the power
lines have stabilised (it's a fixed delay, but an MCLR reset or power-spike
will usually reset the delay counter), and the extra delay is giving your LCD
enough time to sort itself out.

Personally I'd just leave PWRTE on (I usually enable it as standard on most of
my projects anyway) but if you have a PWRTE-phobia, an increase in the delay
between RESET and you start sending commands to the LCD should do much the
same thing. Most of my code tends to look a bit like this:

       ORG 0
       GOTO RESET
       ORG 4
       GOTO INTERRUPT

RESET:
       MOVLW        D'30'
       CALL        DELAYMS                ; wait 30 milliseconds
       CALL        LCD_INIT        ; initialise the LCD
       ; ... do other stuff here ...

--
Phil.
.....piclistKILLspamspam.....philpem.me.uk
http://www.philpem.me.uk/

2009\04\09@074829 by olin piclist

face picon face
Philip Pemberton wrote:
> ORG 0
> GOTO RESET

You forgot PAGESEL RESET between those two instructions.

> ORG 4
> GOTO INTERRUPT

This is really bad.  You will get away with this on single page PICs, but on
multi-page PICs this will fail if PCLATH happened to not be set for the page
INTERRUPT is on at the time of the interrupt.  And this can't be fixed by
doing a PAGESEL before GOTO INTERRUPT because that would corrupt PCLATH.

A much better answer is to put the interrupt routine right at the interrupt
vector.  Some code will live there, so it might as well be the one routine
that benefits from it.

While you're at it, take your code out of the 1990s and use CODE instead of
ORG.  That way you can give it a meaningful section name instead of having
the assembler generate one for you:

reset code    0         ;execution starts here on reset
      pagesel start
      goto    start     ;to relocatable startup code

intr  code    4         ;CPU calls here on interrupt
      ...               ;put the interrupt code directly here
      retfie

strt  code              ;note no address, so this is relocatable
start                    ;jumps here from code at reset vector
      ...               ;startup code goes here


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2009\04\09@082550 by Michael Rigby-Jones

picon face


> -----Original Message-----
> From: EraseMEpiclist-bouncesspam_OUTspamTakeThisOuTmit.edu [piclist-bouncesspamspam_OUTmit.edu] On
Behalf
{Quote hidden}

What kind of oscillator are you using, internal RC or external with a
crystal or resonator?

It's easy to cause problems with veroboard by leaving long tracks
connected to oscillator pins, you should make these as short as possible
by cutting the tracks.

Add decoupling caps on the trace side of the board (i.e. solder them
straight onto the IC pins), trying to connect a decoupling cap between
two sides of an IC by using jumpers to route it around one end of the
chip is ineffective due to the significant inductance that is added, the
capacitor needs to have as short wires as possible.

Unless you have a ver good reason not to use it, then always enable the
power up timer if you are using a crystal or resonator.  I would also
always use the brown out reset unless you are going for an ultra low
power design.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2009\04\09@102024 by Philip Pemberton

face
flavicon
face
Olin Lathrop wrote:
> You forgot PAGESEL RESET between those two instructions.

I also copied that code off the top of my head. In truth, I usually use the
Microchip code templates (the ones you usually find in Program Files\MPASM
Suite\Template\Code and ...\Object), which do have the PAGESEL instructions
(and an interrupt handler sitting right at the ISR entry point). The example
I posted was only intended to show where you might put a call to a startup
delay routine, not as a template for developing other code.

--
Phil.
@spam@piclistKILLspamspamphilpem.me.uk
http://www.philpem.me.uk/

2009\04\09@112038 by Robert LaBudde

picon face
At 04:14 AM 4/9/2009, Rikard Bosnjakovic wrote:
>Thanks everyone for the replies, I have now found a solution so I'll
>answer all questions here.
><snip>
> > Touch the pin with a dielectric to check cold soldering.
>
>4. Did this. Nothing happened when I touched with plastic.

This indicates you have a problem with power-up timing, as others
have already indicated, and you have verified.

When you add capacitance (via a conductive probe) to -MCLR, you
create an RC timing circuit between +Vcc and GND. The size of RC
determines the time constant. Here, R = 10k, as you indicated.
Typically C = 0.1 uF. Using C = 0.01 uF may work, but delays start-up
by only 1/10 of the time as C = 0.1 uF does. You should pick RC to
match your timing requirement and chip specifications.

You can use both an RC circuit on -MCLR and the on-chip power-on
delay. What do you care about a fraction of a second delay on
power-up, when an LCD and user are involved? If you were mass
producing a very small circuit with no interface, and subject to
critical timing, you might forgo these measures. Otherwise there is
no reason not to use them to increase reliability.



==========================================================
Robert A. LaBudde                      Email: KILLspamralKILLspamspampobox.com
824 Timberlake Drive                   Tel: (757) 467-0954
Virginia Beach, VA 23464-3239          Fax: (757) 467-2947
==========================================================

2009\04\09@123521 by Vitaliy

flavicon
face
Philip Pemberton wrote:
> Your code is trying to initialise the LCD before the display controller
> has
> finished powering up.
>
> From experience, most Hitachi HD44780 and Samsung KS0066 based modules
> need a
> good 15-20 milliseconds between Vcc coming up enough for the PIC to boot,
> and
> the display being ready to accept a command. Some LCD modules built by
> manufacturers who really should have read the datasheets can take up to 80
> or
> 90 milliseconds to boot, though these are (thankfully) rare.

I believe Philip hit the nail right between the eyes. When you touch the
MCLR pin with your finger, you reset the PIC but not the LCD controller.

Vitaliy

2009\04\09@194947 by Barry Gershenfeld

picon face
>
> I believe Philip hit the nail right between the eyes. When you touch the
> MCLR pin with your finger, you reset the PIC but not the LCD controller.
>

If I were confronted with problem like this (and I have been) I would leave
the original code as it is, but add a 1 second wait, and then do the init to
the display again.  That way I can do both tests at once.  If it comes up
immediately, then everything is working (at least) as planned.  If it waits
a second and then comes up, I know I'm initializing too fast.  And if it
doesn't come up at all, then it's an unresolved hardware/startup/code
problem.

Also, try touching your voltmeter to MCLR after it's running, and see if the
display redraws itself (processor restarting; but of course your init
sequence must be visible in this case).

More... (looser matching)
- Last day of these posts
- In 2009 , 2010 only
- Today
- New search...