RESET on 08m

AndyGadget

Senior Member
The 08m chip has no RESET command, but is there an 'unofficial' way of doing this.
The most likely way would be a POKE in a critical location (which can floor the best of us :¬)
 

Andrew Cowan

Senior Member
What about using an interrupt on a certain pin?

Or, instead of the reset command,
b0=0
b1=0
b2=0
...
b13=0
make all pins inputs

etc

A
 

AndyGadget

Senior Member
I'm looking to jump out of nested loops on an error condition without first unwinding the stack (terminating the loops cleanly).
I haven't tried it, but I suspect the PicAxe would soon take exception to this as it's stack pointers overflow. A warm reset would reset them and run from scratch.
 

BeanieBots

Moderator
You can exit loops (for/next & do/loop) with the "Exit" command.
Nested gosubs however are another matter.

I'm sure there is a poke which will effect a reset. We'll have to wait for a more official response on that one to know if there are any side effects lurking.

You could of course always do a power cycle triggered by whatever external event makes you want to reset.
 

hippy

Ex-Staff (retired)
Unlike other micro's the PICAXE stack is circular rather than linear so you can just jump to the start of program and not worry about unwinding the stack cleanly.

The only case where this does not work is from within an interrupt routine. You have to RETURN from the interrupt, but then you can jump to start of program.

For example, this works ...

#Picaxe 08M
#Terminal 4800

StartOfProgram:
SerTxd( "RESET" )
Gosub RecursiveGosub
End

RecursiveGosub:
SerTxd( "." )
If pin1 = 1 Then StartOfProgram
Gosub RecursiveGosub
 

AndyGadget

Senior Member
Thanks for the information Hippy.
So it's more a doughnut than a stack. I've never come across that before.
I can jump out of my loops with impunity.

Andy.
 

hippy

Ex-Staff (retired)
Yes like a doughnut - I think the official term is 'circular ring buffer', or some variation upon it.

Most PICmicro's until recently also used the same scheme, although the PICAXE firmware uses a separate stack to the on-chip hardware stack.
 

AndyGadget

Senior Member
Yep, it works!
I'm coding a project where I was a few bytes over on an 08m and couldn't shave them off no matter how I tried. I've done a major re-write which has GOTOs out of nested IFs and the code is an absolute structural abomination, but I've saved around 40 bytes! (Time for more features ;¬) There's a moral in this, but I don't like it.
 
Top