Hardware Reset for the new 18M2+ ?

Profw

Member
I understand the new chip (18M2+) no longer uses pin 4 for a reset, further I understand this is due to the expansion of much needed I/O. My projects rely on pin 4 as a hardware reset, the kids in my class like to push the reset button. I also understand to reset the new M2+ we just have to remove and restore power to the chip. Now my question. Can you use? : If pinc.5 = low then reset
This line of code would be added in your code to simulate the old hardware reset. This also uses new reset command. Will this work?
 
Last edited:

hippy

Ex-Staff (retired)
Can you use? : If c.5 = low then reset
Welcome to the PICAXE forum.

You are correct on the Reset Button issue; this becomes an I/O pin on the 18M2/18M2+ and there is no physical hardware reset button any more. The pin can be monitored for noting the old Reset Button has been pushed; the command would be -

If pinC.5 = 0 Then Reset

This works well inside a loop but for some cases it may be best to use either an interrupt on that pin going low or you can use multi-tasking to add a separate task to detect activation and provide the reset.
 

srnet

Senior Member
Why not just use a normally closed push button switch, with the power supply to the 18M2 running through the switch contacts ?
 

Hemi345

Senior Member
Why not just use a normally closed push button switch, with the power supply to the 18M2 running through the switch contacts ?
I'm guessing Profw is using a RevEd board with the built-in reset button, like the AXE091
 

Profw

Member
Many thanks

Wow, good answers many thanks. OK. The power disconnect switch will work. But, what about the old boards that are already hard wired for a pull low push button with a pull up resistor. If you put the reset code we talked about earlier in a main with gosubs program. It will work, but, not very well as you have to hold down the reset button until some return in the program takes place then indeed it works. Now, how can we generate an interrupt to stop the program execution and start over or reset?
 

Hemi345

Senior Member
at the top of the program, configure the interrupt:
Code:
setint %00000000,%00100000 ;configure C.5 to interrupt on low
then add an interrupt routine:

Code:
interrupt:	
   if pinC.5 = 0 then interrupt	;debounce button
   reset
This will almost immediately reset the PICAXE no matter where it's at in the program provided it's not currently executing a blocking command (e.g., serin).
 
Top