Searching \ for 'Software controlled Hardware reset....' 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/index.htm?key=software+controlled
Search entire site for: 'Software controlled Hardware reset....'.

Truncated match.
PICList Thread
'Software controlled Hardware reset....'
1998\12\22@132550 by D. Schouten

picon face
Hi All,

I'm currently doing a project with a 16C73A in which I require a
software controlled MCLR reset. I need this because I have the
following problem :

When I power-up the PIC the software is running with no problems. When
for example a certain external voltage drop is detected on an A/D
channel (the total unit is battery powered, but the PIC is safely
supplied by a 7805 regulator), the software jumps to a subroutine.
When this external voltage is back to normal again, the software will
be reset by jumping out of the subroutine back to Start (address 0)
initializing all registers again etc. etc.
The problem is that after this 'soft-reset' I experience some problems
with my A/D conversions resulting in large conversion errors. When I
reset the processor by pulling down MCLR, everything works fine again.

So my question is, is it possible to (MCLR) reset the 16C73A just by
using some instructions?
Right now, I've connected an NPN transistor to RA4 to pull down MCLR
when I exit the above mentioned subroutine. But until this doesn't
work yet.

I hope you guys can help me out on this.

Bye,

Daniel...

1998\12\22@144449 by evan

picon face
> On Tues Dec 22 1998 at 10:11am Daniel Schouten wrote:
> When I power-up the PIC the software is running with no problems. When
> for example a certain external voltage drop is detected on an A/D
> channel (the total unit is battery powered, but the PIC is safely
> supplied by a 7805 regulator), the software jumps to a subroutine.
> When this external voltage is back to normal again, the software will
> be reset by jumping out of the subroutine back to Start (address 0)
> initializing all registers again etc. etc.
> The problem is that after this 'soft-reset' I experience some problems
> with my A/D conversions resulting in large conversion errors. When I
> reset the processor by pulling down MCLR, everything works fine again.

Sounds like your PIC A/D module isn't getting properly initialized in the
software, in that your software is relying on a default power-up value for a
bit or register instead of explicitly setting it.  Ensure all A/D-related
registers are set in your software before attempting a conversion.  The
manual has a nice register summary page showing the reset state of all
registers for POR and BOR resets vs. other resets, which may help.

> So my question is, is it possible to (MCLR) reset the 16C73A just by
> using some instructions?
> Right now, I've connected an NPN transistor to RA4 to pull down MCLR
> when I exit the above mentioned subroutine. But until this doesn't
> work yet.

I suppose a self-induced reset can be done using either MCLR or Vdd.  The
advantage of switching the Vdd power to the PIC is that you can take
advantage of the Power-on Reset (POR), Power-up Timer (PWRT), and the
Brown-out Reset circuitry built into the PIC.  If you have brown-out
protection circuitry on MCLR then externally switching Vdd to that circuit
should work fine.  You can maintain the reset pulse for a short while after
the PIC resets with another cap & resistor off the pin used to generate the
reset.  Note that all TRIS bits are "1" after reset, meaning the pins are
inputs, something to keep in mind with self-induced resets.

A watchdog reset will have the same effect on the PIC as a MCLR reset (NOT
Vdd reset), so you might try intentionally "hanging" your PIC until the
watchdog resets it.

-Ed V.
Agile Controls

1998\12\22@162812 by Harrison Cooper

flavicon
face
if your micro is not initialized until it runs thru the part that
says....this port is an output, this is an input, etc (you know what I
mean), that pin you are driving may not be driven...or is actually holding
your clear low forever.  Better would be two pins, gated so it only resets
when both conditions are true (or false..whichever).

1998\12\22@165306 by D. Schouten

picon face
Hi All,

(I'm sorry if this message was posted twice. I received some errors)

I'm currently doing a project with a 16C73A in which I require a
software controlled MCLR reset. I need this because I have the
following problem :

When I power-up the PIC the software is running with no problems. When
for example a certain external voltage drop is detected on an A/D
channel (the total unit is battery powered, but the PIC is safely
supplied by a 7805 regulator), the software jumps to a subroutine.
When this external voltage is back to normal again, the software will
be reset by jumping out of the subroutine back to Start (address 0)
initializing all registers again etc. etc.
The problem is that after this 'soft-reset' I experience some problems
with my A/D conversions resulting in large conversion errors. When I
reset the processor by pulling down MCLR, everything works fine again.

So my question is, is it possible to (MCLR) reset the 16C73A just by
using some instructions?
Right now, I've connected an NPN transistor to RA4 to pull down MCLR
when I exit the above mentioned subroutine. But until this doesn't
work yet.

I hope you guys can help me out on this.

Bye,

Daniel...

1998\12\22@180549 by David W. Duley

picon face
In a message dated 12/22/98 1:54:20 PM Pacific Standard Time,
spam_OUTdanielsTakeThisOuTspamXS4ALL.NL writes:

<< Hi All,

(I'm sorry if this message was posted twice. I received some errors)

I'm currently doing a project with a 16C73A in which I require a
software controlled MCLR reset. I need this because I have the
following problem :

When I power-up the PIC the software is running with no problems. When
for example a certain external voltage drop is detected on an A/D
channel (the total unit is battery powered, but the PIC is safely
supplied by a 7805 regulator), the software jumps to a subroutine.
When this external voltage is back to normal again, the software will
be reset by jumping out of the subroutine back to Start (address 0)
initializing all registers again etc. etc.
The problem is that after this 'soft-reset' I experience some problems
with my A/D conversions resulting in large conversion errors. When I
reset the processor by pulling down MCLR, everything works fine again.

So my question is, is it possible to (MCLR) reset the 16C73A just by
using some instructions?
Right now, I've connected an NPN transistor to RA4 to pull down MCLR
when I exit the above mentioned subroutine. But until this doesn't
work yet.

I hope you guys can help me out on this.

Bye,

Daniel...
 >>
why don't you just jump to a routine that doesn't clear the wdt?  The result
is a hardware reset without hardware.

Dave Duley

1998\12\23@065128 by Dr. Imre Bartfai

flavicon
face
On Tue, 22 Dec 1998, D. Schouten wrote:

{Quote hidden}

I guess the idea is good. However, RA4 can't pull down MCLR wia NPN
because of RA4 is an open-collector output. Either choose another pin, or
pull down MCLR with RA4 directly (ugh).

>
> I hope you guys can help me out on this.
>
> Bye,
>
> Daniel...
>
>

1998\12\23@102534 by paulb

flavicon
face
D. Schouten wrote:

> (I'm sorry if this message was posted twice.  I received some errors)

 Dear me, can we possibly have a line or two added in the introductory
list message to point out that if you receive a "message undeliverable"
message after posting to PICLIST (as is presently happening from the
dreaded ".....UNDELIVERABLEKILLspamspam@spam@SPEASTECH.COM"), *NEVER* to re-post the message?

 I mean, if it is undeliverable, why send it again, eh?  Eh?

> I'm currently doing a project with a 16C73A in which I require a
> software controlled MCLR reset. I need this because I have the
> following problem :

 "Need" is not quite the right word here!  I'm afraid I have some
problems with the "if it doesn't fit, hammer it harder" style of
engineering implicit in both of these quotes.  I wonder what happens if
you later decide you really *do* want more than one set of readings
between hardware resets?

 When I was taught "C", one of the big plus-es (this was before C++ ;-)
was the lack of a "goto" statement.  I suspect tutors/ lecturers still
wax lyrical on this.

> When this external voltage is back to normal again, the software will
> be reset by jumping out of the subroutine back to Start (address 0)
> initializing all registers again etc. etc.

 Forth provides one, and one only, big GOTO.  This re-initialises
everything by re-starting the program, similar to GOTO 0 on most
processors.  But this is an "exception" and specifically returns the
system to user control.  As a deliberate part of the program, even *I*,
spaghetti coder extraordinaire, think this is very poor.

> The problem is that after this 'soft-reset' I experience some problems
> with my A/D conversions resulting in large conversion errors. When I
> reset the processor by pulling down MCLR, everything works fine again.

 This certainly indicates that you are being extremely lazy, not
learning how to set up the ADC properly.  You really need to look at the
manual and read and re-read it until you *understand* every part of the
ADC operation and can write the code to initialise everything.

 As a hint, pay particular atttention to providing settling time delays
before a conversion, as one thing a hardware reset does provide is an
effective settling time.

> Right now, I've connected an NPN transistor to RA4 to pull down MCLR
> when I exit the above mentioned subroutine.  But until this doesn't
> work yet.

 It's not entirely obvious what you mean, but it's significant that RA4
is an open-collector driver on many/ most? devices, so if you expect it
to drive an NPN transistor, you may wait a l-o-n-g time!  OTOH, if you
connect it *directly* to MCLR, it should work fine!  *If* that's really
what you want.
--
 Cheers,
       Paul B.

1998\12\23@173014 by James Cameron

flavicon
face
Paul B. Webster VK2BZC wrote:
> When I was taught "C", one of the big plus-es (this was before C++ ;-)
> was the lack of a "goto" statement.  I suspect tutors/ lecturers still
> wax lyrical on this.

Um, C has a "goto".  Are you thinking of PASCAL?

main()
{
loop:
       thing();
       goto loop;
}

Admittedly you don't often _need_ to use a "goto".

main()
{
       while(1) thing();
}

But I think it is not as evil as setjmp() and longjmp().

--
James Cameron                                      (cameronspamKILLspamstl.dec.com)

OpenVMS, Linux, Firewalls, Software Engineering, CGI, HTTP, X, C, FORTH,
COBOL, BASIC, DCL, csh, bash, ksh, sh, Electronics, Microcontrollers,
Disability Engineering, Netrek, Bicycles, Pedant, Farming, Home Control,
Remote Area Power, Greek Scholar, Tenor Vocalist, Church Sound, Husband.

"Specialisation is for insects." -- Robert Heinlein.

1998\12\23@175113 by paulb

flavicon
face
James Cameron wrote:

> Um, C has a "goto".  Are you thinking of PASCAL?

 OK, you got me there :)  It's been a while!

> But I think it is not as evil as setjmp() and longjmp().

 Is that a sort of takeajmp() ?
--
 Cheers,
       Paul B.

1998\12\23@181021 by Gerhard Fiedler

picon face
At 09:18 12/24/98 +1100, James Cameron wrote:
>But I think it is not as evil as setjmp() and longjmp().

and not half as useful either... in most cases where one would use a goto,
you could make it without it also, but try to do the same thing you do with
setjmp() without it...

ge

1998\12\23@184213 by James Cameron

flavicon
face
Paul B. Webster VK2BZC wrote:
> James Cameron wrote:
> > But I think it is not as evil as setjmp() and longjmp().
>   Is that a sort of takeajmp() ?

setjmp() marks a point in your code.

longjmp() can be used anywhere in the code to unwind the stack, all
stack allocated variables, and resume execution after the setjmp().

It is sort of a steroidal or global goto; can be used in any part of a
program, not just within a function.

I imagine it would be difficult to implement on PIC ... requires ability
to unwind (pop) the stack.  Means the compiler would have had to
implement the stack as a set of file registers.

--
James Cameron                                      (.....cameronKILLspamspam.....stl.dec.com)

OpenVMS, Linux, Firewalls, Software Engineering, CGI, HTTP, X, C, FORTH,
COBOL, BASIC, DCL, csh, bash, ksh, sh, Electronics, Microcontrollers,
Disability Engineering, Netrek, Bicycles, Pedant, Farming, Home Control,
Remote Area Power, Greek Scholar, Tenor Vocalist, Church Sound, Husband.

"Specialisation is for insects." -- Robert Heinlein.

1998\12\23@184421 by J Nagy

flavicon
face
> So my question is, is it possible to (MCLR) reset the 16C73A just by
> using some instructions?
> Right now, I've connected an NPN transistor to RA4 to pull down MCLR
> when I exit the above mentioned subroutine. But until this doesn't
> work yet.
>
> I hope you guys can help me out on this.
>
> Bye,
>
> Daniel...
>  >>
>why don't you just jump to a routine that doesn't clear the wdt?  The result
>is a hardware reset without hardware.
>
>Dave Duley

Even simpler would be a jump to your initialization routine(s). If these
are complete, you really shouldn't have any need for a hardware reset.
Perhaps you missed something in your initial attempt (a register clear or
some such thing) that a MCLR does for you.

       Jim Nagy
       Elm Electronics
Makers of unique integrated circuits
http://www.elmelectronics.com/

1998\12\23@192653 by Mark Willis

flavicon
face
James Cameron wrote:
{Quote hidden}

 Ahem.  Pascal (at least some implementations!) has a Goto, as well.

 Turbo Pascal, for example <G>

 (I don't remember if the UW's CDC Cyber type Pascal has one, as I have
a printout of the source somewhere I could go look someday but that's in
storage <G>)

 The mere existence of something doesn't make it evil IMHO;  MISUSE of
that thing, does.  I don't do Basic, for this reason <G>

 Mark

1998\12\24@080530 by paulb

flavicon
face
Dr. Imre Bartfai wrote:

> I guess the idea is good.  However, RA4 can't pull down MCLR wia NPN
> because of RA4 is an open-collector output.

 I believe I said the same, FWIW.  This spooks me when we say the same
thing separately!

> Either choose another pin, or pull down MCLR with RA4 directly (ugh).

 Precisely why is using RA4 "Ugh"?  Being open-collector, it has
limited other uses, but is perfect for MCLR and it isn't going to be
activated prematurely as like other I/O, it defaults to input.
--
 Cheers,
       Paul B.

1998\12\24@080740 by paulb

flavicon
face
James Cameron wrote:

>>> But I think it is not as evil as setjmp() and longjmp().
>>   Is that a sort of takeajmp() ?

> setjmp() marks a point in your code.
> longjmp() can be used anywhere in the code to unwind the stack, all

 Err, yes.  Can I mention that was tongue-in-cheek?
--
 Cheers,
       Paul B.

1998\12\28@090952 by uter van ooijen / floortje hanneman

picon face
> Um, C has a "goto".  Are you thinking of PASCAL?

Pascal has a goto, although its use is discouraged (even more than in C).

Wouter.

1998\12\28@095605 by Andy Kunz

flavicon
face
Any of you guys ever hear of a COMEFROM?  It's like the opposite of a GOTO!

<G>

At 10:30 AM 12/24/98 +1100, you wrote:
{Quote hidden}

==================================================================
 Andy Kunz - Montana Design - http://www.users.fast.net/~montana
==================================================================


'Software controlled Hardware reset....'
1999\01\05@081503 by Dmitry Kiryashov
flavicon
face
James Cameron wrote:

> setjmp() marks a point in your code.
>
> longjmp() can be used anywhere in the code to unwind the stack, all
> stack allocated variables, and resume execution after the setjmp().
>
> It is sort of a steroidal or global goto; can be used in any part of a
> program, not just within a function.
>
> I imagine it would be difficult to implement on PIC ... requires ability
> to unwind (pop) the stack.  Means the compiler would have had to
> implement the stack as a set of file registers.

Hmm. What the problem to implement the stack of return's in software ?
Hint: movwf pcl,f (or movwf pclath,f) still work. ;-)

Back to original topic.

I think additional capacitor will be required. MCLR is pulled up
via resistor, connected through another resistor to RA4 and cap
from MCLR to ground. When RA4 are become low capaciotor is dis-
charged -> PIC'll reseted and RA4 become high again. The cap is
required to obtain some duration of low level at RA4 for instance
to reset simultaneously some external hardware. Also diod in parallel
with pull-up resistor will be helpful to quickly discharge the cap
when power is off.

;The example of code

       bcf     _gie
       btfsc   _gie
       goto    $-2

       movlw   0xEF    ;111_0_1111
       tris    PORTA
       movwf   PORTA

       goto    $       ;wait for reset
;

WBR Dmitry.

1999\01\05@113513 by John Payson

flavicon
face
|setjmp() marks a point in your code.

|longjmp() can be used anywhere in the code to unwind the stack, all
|stack allocated variables, and resume execution after the setjmp().

|It is sort of a steroidal or global goto; can be used in any part of a
|program, not just within a function.

|I imagine it would be difficult to implement on PIC ... requires ability
|to unwind (pop) the stack.  Means the compiler would have had to
|implement the stack as a set of file registers.

Although it may be used in other places, setjmp() is probably used
most commonly within main(), a routine which is never going to return.
As a result, the stack contents are irrelevant.  Although setjmp and
longjmp may not be practically implemented for the "general case",
there's no problem making a special-case version which requires that
the setjmp() call be performed within main().

1999\01\05@224430 by James Cameron

flavicon
face
John Payson wrote:
> Although it may be used in other places, setjmp() is probably used
> most commonly within main(), a routine which is never going to return.

Well, this makes it so easy then ...

setjmp() { return; }
longjmp() { main(); }

... so easy that it is not worth the effort of a compiler writer to do
it, document the non-standardness of it, and then put up with the
support issues that would result.  ;-)

--
James Cameron                                      (@spam@cameronKILLspamspamstl.dec.com)

OpenVMS, Linux, Firewalls, Software Engineering, CGI, HTTP, X, C, FORTH,
COBOL, BASIC, DCL, csh, bash, ksh, sh, Electronics, Microcontrollers,
Disability Engineering, Netrek, Bicycles, Pedant, Farming, Home Control,
Remote Area Power, Greek Scholar, Tenor Vocalist, Church Sound, Husband.

"Specialisation is for insects." -- Robert Heinlein.

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