MCLR on 16F84
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
MCLR on 16F84
The MCLR pin is used only as a reset pin in the 16F84 / A.
A switch can be added to reset the device by placing a push to break switch between +5v and a 1K resistor. The resistor the joins to the MCLR pin and a capacitor is used between the MCLR and ground to add stability.
EG
5V----Switch----1K Res-----MCLR-----Capacitor----GND
This will act to drive the reset pin when the switch is pressed.
A switch can be added to reset the device by placing a push to break switch between +5v and a 1K resistor. The resistor the joins to the MCLR pin and a capacitor is used between the MCLR and ground to add stability.
EG
5V----Switch----1K Res-----MCLR-----Capacitor----GND
This will act to drive the reset pin when the switch is pressed.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Thats right ksor the MCLR will automatically have this property and reset the software when the 5v connection is broken. If you wanted you could add a software interrupt to happen upon a reset to process a certain bit of code but this is only if you need this functionality.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 209
- Joined: Thu Oct 19, 2006 11:46 am
- Location: Bakewell, UK
- Has thanked: 20 times
- Been thanked: 16 times
- Contact:
MCLR through software
My take on the question is 'can you effect MCLR through software in Flowcode'. This is akin to part of my earlier post about a week ago.
Having pondered (and used) the suggestion of directing code execution to memory 0 (see response of Steve to my post) this does not actually do the same thing as internal registers are not all reset.
The only 'solution' I can think of is to set the watchdog timer and deliberately fail to clear at some stage in coide execution it so as to effect a simulated hard reset.
Having pondered (and used) the suggestion of directing code execution to memory 0 (see response of Steve to my post) this does not actually do the same thing as internal registers are not all reset.
The only 'solution' I can think of is to set the watchdog timer and deliberately fail to clear at some stage in coide execution it so as to effect a simulated hard reset.
Go with the Flow.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Mark,
The software reset could be done as you say by setting the program counter to location 0 if you make sure that all of the registers and reset. Another way would be to use an output pin to switch off the power to the MCLR using a transistor connected between MCLR and ground. The software could then reset at any time it wants by outputting a high on the output pin switching on the transistor.
The software reset could be done as you say by setting the program counter to location 0 if you make sure that all of the registers and reset. Another way would be to use an output pin to switch off the power to the MCLR using a transistor connected between MCLR and ground. The software could then reset at any time it wants by outputting a high on the output pin switching on the transistor.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 209
- Joined: Thu Oct 19, 2006 11:46 am
- Location: Bakewell, UK
- Has thanked: 20 times
- Been thanked: 16 times
- Contact:
Benj,
Nice idea.
Presumably the port pins will all be set low on a reset so that the device will not get stuck in a reset forever situation? I thought that all pins were set as inputs on startup so that the state of any pin to an output device would be indeterminate. I.e. it may never be possible to recover from such a reset as the output to the transistor base may never go low and so code could never restart?.
I still like the idea
If the idea is from a Advice note, or the like, then please post the link.
Thanks
Nice idea.
Presumably the port pins will all be set low on a reset so that the device will not get stuck in a reset forever situation? I thought that all pins were set as inputs on startup so that the state of any pin to an output device would be indeterminate. I.e. it may never be possible to recover from such a reset as the output to the transistor base may never go low and so code could never restart?.
I still like the idea
![Smile :)](./images/smilies/icon_smile.gif)
If the idea is from a Advice note, or the like, then please post the link.
Thanks
Go with the Flow.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Thanks Mark
Your right about the possibility of never recovering from a reset however with a little tweaking and a pull down resistor to overcome the indeterminate startup state it may still be possible.
Sorry the idea is out of my head
so not 100 percent about it but think it certainly has possibilities.
Let me know if you decide to give it a trial.![Laughing :lol:](./images/smilies/icon_lol.gif)
Your right about the possibility of never recovering from a reset however with a little tweaking and a pull down resistor to overcome the indeterminate startup state it may still be possible.
Sorry the idea is out of my head
![Idea :idea:](./images/smilies/icon_idea.gif)
Let me know if you decide to give it a trial.
![Laughing :lol:](./images/smilies/icon_lol.gif)
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel