Searching \ for '[PIC]: Random code on startup?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/math/index.htm?key=random
Search entire site for: 'Random code on startup?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Random code on startup?'
2000\11\29@131130 by Drew Vassallo

picon face
Is it at all possible that occasionally on power-up, the program in a PIC
(I'm using a 16c71) begins NOT at PCL=0?  In my program, all I have is some
setup code to initialize the ports, disable interrupts, and set some
literals.  Immediately after this code, I turn a LED on.  Sometimes when I
start up after powering the PIC down, I get no outputs at all, and the LED
doesn't even turn on.  I'm sure power is getting to the PIC, but it seems
not to start up at the beginning of the program sometimes.

Anyone have any ideas on this?  It's pretty frustrating to power up only to
have some odd sequence of code running, then have to continually power down
and up until it appears to work.

By the way, it didn't do this until I added some I^2C code in the program,
but this code isn't accessed until later in the program.  I'm wondering if
there might be something wrong with the port initialization with the memory
device attached.  I'm really grasping at straws looking for answers.

Thanks for any advice.
_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\11\29@134030 by DERRICK, Keith

flavicon
face
I'm a softie, so if it's a hw problem I can't help. However, here are some
painfully learnt lessons to give you some leads.

Do you have an external resonator/crystal? Is it always restarting?

Do you have the watchdog enabled? Have you added some initialisation code
which could take you over the watchdog limit? This is a prime candidate,
especially with a bus like I2C where the time to perform an operation can
vary depedning on response speed of the slave device.

Do you have interrupts enabled during initialisation? Any chance one is
firing and changing your initialisation path? Or firing before you're ready
for it?

Have you tried simulating using Mplab? Does the error occur there, or only
in hardware?

You don't mention if you have an ICE. If so, does the error occur in both
ICE and the device? Or are you just observing the behaviour and hoping for
inspiration? 8)

If you turn on the LED then go on to do I2C (your new code), it's possible
that the error is occurring in that code; causing a reset; which turns off
the LED again. If the LED is not on long enough, you might not notice it.
Look real close and see if it's actually glowing very dimly 8) This would
suggest a rapid duty cycle with it off considerably more than it is on.

After that, my only suggestion is that either you find a way to make it
reliably reproducible (i.e. >90% of the time) or start removing code until
it works again.

Either way, reproducibility is the key. Without it, you'll never know if
you've fixed the problem or just reduced its frequency.

Keith Derrick

{Original Message removed}

2000\11\29@135521 by Bob Ammerman

picon face
Is your Vcc coming up quickly enough?

Is it monotonically increasing?

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\11\29@142058 by Mike Mansheim

flavicon
face
<<...
literals.  Immediately after this code, I turn a LED on.  Sometimes when I
start up after powering the PIC down, I get no outputs at all, and the LED
doesn't even turn on.  I'm sure power is getting to the PIC, but it seems
...>>

another possibility:
you may have bulk supply caps (or something else) on your board that cause
Vcc to decay when you power down, rather than step change to 0V.  If you
power down, then start back up too quickly, Vcc doesn't drop enough and the
pic never actually stops running - so you are still in the looping "main"
part
of your program.
We had an application where the board was powered by an alternator from a
small
gas engine - the ac was rectified and smoothed with 2 1500uf caps.  The
on/off
switch broke one of the ac lines - one could easily flip the switch off and
back on without rebooting the processor.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\11\29@145908 by Drew Vassallo

picon face
>another possibility:
>you may have bulk supply caps (or something else) on your board that cause
>Vcc to decay when you power down, rather than step change to 0V.  If you
>power down, then start back up too quickly, Vcc doesn't drop enough and the
>pic never actually stops running - so you are still in the looping "main"
>part
>of your program.

If this were true, my "power-up" would still give me normal operation of the
PIC program.  As I said, I get no outputs and no activity through the lines,
but power is on.  However, I'm not sure that power isn't coming down FAR
ENOUGH to cause a partial reset, yet is still high enough to keep the
oscillator running.  I've measured roughly 0.5V at the power pins when the
switch is off, which decays to zero after many minutes.  I assumed this
wasn't enough to keep the PIC even partially on.

I appreciate all the ideas, yet none of them seem to apply to my situation.
WDT is disabled and interrupts are all disabled immediatelly after
initializing all Bank1 registers.  Am I correct in assuming that no matter
what the PIC is currently doing, or what processes are driving the lines,
that when the power is shut off and back on again, the PIC restarts at the
beginning?  Is this not true?

Thanks again.
_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\11\29@151757 by frmiller

flavicon
face
I'm pretty sure that your problem is that your power isn't
coming up fast enough. I had the same problem with a
PIC16C73. I solved it by using the brownout circuit shown in
the data book (the simple one with the PNP and 3 resistors).
This holds the PIC in reset until the power comes up enough.

Ryan


{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\11\29@152008 by Dwayne Reid

flavicon
face
At 01:11 PM 11/29/00 -0500, Drew Vassallo wrote:
>Is it at all possible that occasionally on power-up, the program in a PIC
>(I'm using a 16c71) begins NOT at PCL=0?

I've had similar problems that have been tracked down to 1 thing: power
supply.  You *MUST* ensure that the power supply reaches 5V within 20 ms or
so *and* that VDD drops to less than 0.2Vdc when power is removed.

Experience is a tough teacher.  Every PIC design I do these days either has
an external reset controller or has a power supply that keeps VDD removed
until the unregulated supply is above the dropout voltage of the
regulator.  I have several versions - all are simple.  The simplest is a
5.1V zener with a 470R to 1k0 resistor from my unregulated supply of 15V
nominal.  Shunting the zener is a J175 depletion mode FET with a 100K or so
resistor from the gate to the unregulated supply.  Note that you can get
only a few mA from this supply, but most of my designs need only a few
mA.  The FET keeps VDD at less than 0.1V until the unregulated supply rises
above about 10V.

Another version (also zener regulated) has the input resistor (470R - 1k0)
connected to the emitter of a 2n4403 PNP transistor.  The base of the
transistor connects to the cathode of a 4.3V zener; anode to gnd.  The
collector of the transistor feeds +5V switched to the circuit.  The
transistor does not turn on and apply power to the circuit until the
unregulated supply rises high enough for the zener to start regulating.  A
resistor from VDD to gnd ensures that the supply collapses to 0V when the
supply shuts down.

A variation on the above circuit (PNP transistor) has the collector of the
transistor feeding MCLR on the PIC, with a pull-down to either gnd (18 pin
devices) or -15V (12c508).  The negative pull-down is needed (and was
available) because of the weak pull-up on MCLR within the 12c508.

Yet another version uses a couple of transistors configured as a schmitt
trigger.  This is used on a high reliability card used with PLC controllers.

I use a variety of circuits because I deal with a variety of power
sources.  Some applications benefit from the increased current drain while
the power supply is shut down (FET version) - the power source impedance is
fairly high.  A couple of high volume (for us) projects have a negative
unregulated supply available only - that means that VDD is common to the
incoming power supply, not VSS.

I am not aware of any problems with power-up problems happening in the
many, many thousands of units shipped since I started using the above
techniques.  It was a sporadic problem prior to that and it took a lot of
work duplicating field conditions to identify the cause of the problem.

dwayne



Dwayne Reid   <spam_OUTdwaynerTakeThisOuTspamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 16 years of Engineering Innovation (1984 - 2000)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\11\29@152631 by Dan Michaels

flavicon
face
Drew Vassallo wrote:
>Is it at all possible that occasionally on power-up, the program in a PIC
>(I'm using a 16c71) begins NOT at PCL=0?  In my program, all I have is some
>setup code to initialize the ports, disable interrupts, and set some
>literals.  Immediately after this code, I turn a LED on.  Sometimes when I
>start up after powering the PIC down, I get no outputs at all, and the LED
>doesn't even turn on.  I'm sure power is getting to the PIC, but it seems
>not to start up at the beginning of the program sometimes.
>
>Anyone have any ideas on this?  It's pretty frustrating to power up only to
>have some odd sequence of code running, then have to continually power down
>and up until it appears to work.
>

Hello Drew,

There is a possibility that you are not erasing the PIC for
a long enough time between re-programming cycles. A couple of
years ago, I was having flaky code execution with some PIC73/JW
parts, during heavy development efforts [ie, lots of erases &
recodes], and decided erase time was one of several problems.

I have more info on "flaky" PIC operation on my site:

http://www.oricomtech.com/piclinks.htm

regards,
- Dan Michaels
Oricom Technologies
===================

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\11\29@155117 by Olin Lathrop

face picon face
> By the way, it didn't do this until I added some I^2C code in the program,
> but this code isn't accessed until later in the program.

Could this have cause the other code to be moved in memory such that page
and/or bank bits are now different?  There may have been a bug all along
with page/bank bits that has only now surfaced.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, .....olinKILLspamspam@spam@embedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\11\30@053819 by JP.BROWN

flavicon
face
I had a similar problem to this (pic circuit unreliable start up)
as a last resort I added the reset circuit shown in the Microchip
manual (the one with 2 Rs, a C  and a diode) and I never had the
problem since. Also if you are using a JW part (with a window) make sure
you cover the window as light going in through the window can change
things in the pic logic circuits. This all assumes you havn't got a
software bug!, if you can cure the problem by removing certain blocks of
code then examing that code very carefully.

On Wed, 29 Nov 2000, Drew Vassallo wrote:

{Quote hidden}

         -----  John P. Brown      J.P.BrownspamKILLspambradford.ac.uk ----
          \            --- Witty remark goes here ---         /
           --------------------------------------------------

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.



'[PIC]: Random code on startup?'
2000\12\01@042009 by Peter L. Peres
picon face
This is the typical symptom of a PIC (or other CMOS processor) not
starting from Reset. If power comes too slowly or if it does not go low
enough to make the internal reset circuit notice it is low then the
processor will start (or continue) execution from an undefined state. To
confirm, use a reset button temporarily mounted on MCLR. If this always
fixes the problem, then a reset monitor or watchdog on operation is a good
idea imho.

Peter

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2000\12\01@053102 by JP.BROWN

flavicon
face
The first few pic circuits I built were very tempramental some days they
would start up some days they wouldn't, I was realy puzzled. Then I
noticed that when I checked the voltages around the 16F84 pins just
touching the MCLR pin would bring the circuit to life. So I changed the
reset pull up from a simple resistor to Vcc to the one shown in the pic
manual (with a diode and capacitor) since then I have not had this
problem with any of the many 16F84 circuits I have built.

---- John

On Thu, 30 Nov 2000, Peter L. Peres wrote:

{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


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