Published: Thursday, 22 March 2012
Written by Jon Chandler
A reset button press or power being applied to a PIC will result in program execution and running the initialization routines in the program. I would like to execute a branch of my code with configuration options only when the reset button (which is accessible only by removing a panel with four screws) and not during a startup that would occur when power is applied. The question is if it's possible to differentiate between these events.
A bit of background. The /MCLR (Master Clear) line is normally pulled high with a 10k resistor. A reset switch pulls /MCLR to ground, causing a reset. It's essential that this line not be left floating. It may be disabled and used as a normal digital line but this can create difficulties when using ICSP.
I used an 18F2520 for this example, but other 18F-series parts are similar although the means of individual bits may be different.
The first stop is the data sheet. There is an entire section named Reset, so that's a good place to start. The RCON register has the status of various reset options. WDT (watch dog timer), software reset, POR (power on reset), BOR (Brown Out Reset) are among the options.
Read more: Detecting a Reset Button Press in Swordfish
Discuss this article in the forums (0 replies).