software reset?

ipm2404

Member
Is there any way to conduct a software reset?

Would tying the reset pin high via a 4k7 resister then to an i/o pin be okay.
Then when a reset is wanted setting the i/o pin low work?

I want to know before i do it if something like that could work so i don't accidentally fry my 28x.

 
 

SD2100

New Member
Havn't tried it but just a thought, when the 28x is powered up all the outputs would be low, in your case this would cause the 28x to reset straight away causing an endless reset condition, the program would never get to the point where the output goes high.

I'd be more inclined to maybe use an NPN transistor with the emitter to 0V and collector to the reset pin and the usual 4.7k resistor from the reset pin to 5v so a high on an output causes the reset pin to go low. someone else might have a better idea.

If your program is running OK then why do a reset ???



Edited by - Phil75 on 02/11/2006 09:48:15
 

Jeremy Leach

Senior Member
On powerup the i/o pins are set to be inputs by default and high impedance. So by then executing <i>Low &lt;Pin Number&gt; </i> you'll then reset.

But not sure what state the pins are after <i>reset </i> because I'm not sure if reset is exactly equivalent to power up??
 

SD2100

New Member
So you would have to leave the pin for resetting as an input until you wanted to do a reset, you couldn't use for eg:
SYMBOL RESET = 1 as this would make the pin an output and cause it to go low. Unless you did
HIGH 1
SYMBOL RESET = 1

Edited by - Phil75 on 02/11/2006 10:30:44
 

hippy

Technical Support
Staff member
It can be done, and I've use an 08/08M to reset other PICAXE's. As Phil75 suggests, providing reset is pulled-high via an R, an 'output' set as an input won't reset the traget chip, only when it is an output and also low. If a Reset button is fitted it makes sense to also use a blocking diode to protect the output should it be set high and is shorted to 0V when pushed ...<code><pre><font size=2 face='Courier'>+5V ---------------------.---------------.
.|. |
1N4148 4K7 | | .---..---. |
|_| | | |
| X4 X1 | | /| | | | |
| I3 X2 |---|&lt; |----.---^---| RESET | |
`--------' | \| | | | |
08/08M | .---| 0V +V |--'
.-| o | | |
&quot;RESET&quot; `-| o | `--------'
| |
0V ------------------^---' TARGET </font></pre></code> Self-resetting is a bit more complicated. On the 18-range the outputs are only ever outputs, and are initialised low and will keep putting the chip into reset. You'll need an inverter which is also tolerant to the very brief period the 'outputs' are floating inputs when the physical reset starts.

Another problem could be that the chip may reset but not set the 'outputs' as inputs until the point it is released from reset and thus once you assert a reset it stays that way. You'd have to experiment.

Same problem with the 28-range and 40X for any pins which are not initialised as inputs.

The easiest solution is to send a signal from any Outpt or I/O line to a PICAXE-08 which then resets the target and releases it from reset in a reliable, controlled and timed fashion. That PICAXE can have a LED or Piezo so you can indicate when reset is being activated, which helps debugging.

Edited by - hippy on 02/11/2006 13:26:03
 

premelec

Senior Member
A hardcore reset [sometimes inadvertently] can be caused by lowering the Vcc to the PICAXE below it's operating range briefly - either shorting to ground a few microseconds or modulating the control pin on a 3 terminal regulator feeding the PICAXE - in the shorting case it would be prudent to put 10 ohms between the power supply and PICAXE [but leave .1uf on PICAXE] - the reset pulse can be generated by a MOSFET connected to a PICAXE output pin. I have noted in a 08M circuit I have running that when the battery gets low it continuously resets as the voltage drifts upward after getting too low.... crude, dude! whatever works...
 

wilf_nv

Senior Member
Just a thought: While the WDT is used to time the SLEEP interval, perhaps it could also be used to force a true software reset?

Edited by - wilf_nv on 02/11/2006 18:38:09

Edited by - wilf_nv on 02/11/2006 22:17:31
 

wilf_nv

Senior Member
AFAIK

The Watch Dog Timer register on a 08M is located at SFR $18.

The WDT can have two effects:

1) If in the SLEEP mode, terminate SLEEP.
2) If in the RUN mode, RESET by jumping to address 00.

In the middle of some existing code I used poke $18,01 to enable the WDT and it does appear to cause a software reset.

Caution though, I don't know if there are any possible bad side effects for example if used as a single program line.

wilf








Edited by - wilf_nv on 03/11/2006 00:25:21
 

steirny

Member
Wasn't there a recent thread where somebody mentioned taking the serial download line high. You could hook that to an output which must be driven high. You may need a diode to isoltae the output from a real download. No problem with permanent low states. Should work for all the devices, 08 to 40X.
 

hippy

Technical Support
Staff member
steirny : Excellent solution.

A diode from an output pin, pointy end straight to Serial In leg should do the trick.
 

wilf_nv

Senior Member
I spoke too soon. The WDT appears to be permanently enabled and so cannot be turned on and off by poking register $18 bit 0. Register $18 bit2-5 are the WDT prescaler bits and these are normally loaded by the NAP and SLEEP commands. By poking $18 with 01 I was in effect changing the WDT prescaler by a factor of 8 and it was the effects of this that I observed in my program.

Learned quite a bit about this special register which I thought I'd pass on so it was not a waste of time.

wilf
 

wilf_nv

Senior Member
Argh! I just didn't notice the PCL in that forest of SFRs. In a 08M, just POKE $82,0 to generate a software reset.

wilf
 

hippy

Technical Support
Staff member
I'mot sure 'POKE PCL,$00' is as reliable as it could be or at all safe.

That zeroes the bottom 8-bits of the Program Counter only so jumps to the first instruction of the 256-byte code block the PICmicro is executing in. If that is the first code block you will get a jump to the Reset Vector, but otherwise it goes to some 'random code'.

That code may fall through and cause execution from the Reset Vector, but on the way you can't guarantee what it might do, including setting inputs as outputs, excessive writes to Eprom, and numerous other nasty things which could potentially damage the PICAXE and external hardware.

Because the PICAXE is an interpreter, you can't poke PCLATH then PCL because it will not likely ever get to the second poke.
 

wilf_nv

Senior Member
I agree that there may be some risk to my 08M chip in this experimental approach, and I aggree that poking only the LSB of the Program Counter with $00 would normally have unkown consequences.

There is more between Vcc and ground than meets the eye and while this is just an exercise to get to know the chip a little better, I just may stumble on some hidden treasure.

In this case, it appears I was lucky that the basic interpreter executes the instruction POKE $82,00 in a consistent way (for a given chip firmware revision) and that whatever actual jump address (if the resulting jump is not to $000), its side effects seem to be harmless and it does results in a true software reset.

Assuming the WDTE bit is set in the CONFIG register (2007h) the reset is probably from the WDT timing out. More experiments are needed to check the status bits of the STATUS register determine what causes the reset.

wilf
 

dunadd

New Member
Hi Guys ,
Maybe I am missing something, but why would you want to do a software reset? If your program is still running (which it would need to be to do any of the above) why not just &quot; goto START &quot; and start over at the beginning of your program and re-initialze .
 

Brietech

Senior Member
dunadd

-I could think of a couple reasons, but mainly so that you do not have to initialize things like variables (b0-b13) in your code. In situations where every byte counts, especially on something like an 08m, wasting several bytes just to set all of your variables to something predictable (i.e. 0) could be painful/undesirable.
 
Top