MCLR on 16F84

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
ksor
Posts: 126
Joined: Mon Oct 23, 2006 3:50 pm
Contact:

MCLR on 16F84

Post by ksor »

Hoow can I connect a switch to this pin ?

User avatar
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

Post by Benj »

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.

ksor
Posts: 126
Joined: Mon Oct 23, 2006 3:50 pm
Contact:

Post by ksor »

Yes I know - but how can I do exactly this in FlowCode ?

............

aaah - maybe I don't because there is no code behind this functionality.

Is that the correct answer ?

User avatar
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:

Post by Benj »

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.

Mark
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

Post by Mark »

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.
Go with the Flow.

User avatar
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:

Post by Benj »

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.

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Post by Mark »

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
Go with the Flow.

User avatar
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:

Post by Benj »

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 :idea: so not 100 percent about it but think it certainly has possibilities.

Let me know if you decide to give it a trial. :lol:

Post Reply