How to determine cause of restart on 40X2 ?

Buzby

Senior Member
Hi,

I need to determine if my 40X2 was started by power-up or by the reset pin.

There is probably a PIC register that holds this info, but can the PICAXE access it ?.

Cheers,

Buzby
 

Technical

Technical Support
Staff member
RCON would be the register to peeksfr, but that may not give you the detail you need.

There are also other kinds of reset to account for e.g. reset command or even timeout after a failed download attempt.
 

Buzby

Senior Member
Tried peeksfr $D0, but it doesn't change value. It always has the bottom 5 bits set, as if the chip has not been reset or started at all.

Code:
[color=Blue]pause [/color][color=Navy]2000[/color]
[color=Blue]peeksfr [/color][color=Navy]$D0[/color][color=Black], [/color][color=Purple]b0[/color]
[color=Blue]sertxd ([/color][color=Black]#[/color][color=Purple]b0[/color][color=Black],[/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)[/color]
Does the PICAXE firmware reset these bits before I can read them, or am I looking in the wrong SFR ?

Cheers,

Buzby
 

Buzby

Senior Member
Has anybody got any ideas here ?

Am I reading the correct sfr ?.

If so, why does it show the same value for both scenarios ?

Buzby
 

Technical

Technical Support
Staff member
We don't think what you want to do is possible using internal registers, as after the event the firmware will immediately clear any flags after processing the reset.
 

premelec

Senior Member
@Buzby You can look for power glitch by putting in a current or voltage sense on the power line which requires manual reset if it's dropped below some value etc - takes a bit of doing in external hardware. Presumably you have reset pin well anchored.
 

Buzby

Senior Member
Oh well, it was worth checking.

The PIC documentation recommends reseting the flags after they've been processed, so it's no surprise the firmware does this.

Thanks,

Buzby
 

Buzby

Senior Member
Hi Premelec,

Reset pin has a button and resistor, PSU has no detection facility, and the PCB design won't be altered unless the project takes off big.

The only control the device has is an IR, and and settings made via IR are stored in eeprom, so when it wakes up it just carries on where it left off.

The reset button was only for use during development, then I had an idea that I could use it to reset to default settings if it was pressed, but use the stored settings if the device was just switched off and on.

No major problem, just a case of 'nice to have' and mission creep.

Cheers,

Buzby
 

techElder

Well-known member
Then don't use the official reset pin. Reset with a different pin and set the condition to be checked on power up.
 

hippy

Technical Support
Staff member
One option may be a resistor plus cap between V+ and 0V, read the cap via ADC or a digital input. Those may be fairly easy to tack on to the track side of the existing board.

If the input is low when you read it at the start of the program then the capacitor is still being charged up after a power-on, if high then it was already charged up and the restart must have been a reset.
 

Buzby

Senior Member
Hi hippy,

As usual, you've come up with the most effective solution.

Unfortunatley it's too late, the board is in the mail !.

If the customer is happy with the general functionality of this prototype board, and decides he wants more, then I shall update the PCB with this, and a few more, improvements.

Cheers,

Buzby
 
Top