Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

when to tie MCLR to VDD?

Status
Not open for further replies.

Hank Fletcher

New Member
I've just been tinkering around with my 16F88s and I'm not 100% sure about how and when to use the MCLR pin. I can't remember exactly how I learned this, but I've been setting the MCLR configuration bit on, I think because I was having trouble using the internal oscillator with it off.

If I have MCLR on, do I need to tie it to VDD? Could someone help me understand the function of this pin, and for instance, if I'm not using its functions, can I just leave it be?

Just to be sure, I'm going to check that MCLR OFF vs. internal oscillator situation again. Back in a minute.
 
Hi,
MCLR is master clear, or reset. It is an active low input, so we need to tie it up to Vdd during operation. For PIC16F88, it can be internally tied to Vdd, so it can be used as RA5 input.
If you need to reset the PIC, just add a pull up resistor as usual. If you don't use the reset like me, just tie up to Vdd or internally pull up by changing the configuration bit.
 
Thanks! I think I had started setting MCLR ON as an erroneous solution to a programming problem a while back. I can't remember what the problem was, so I'm going to presume (pretend?) that I must have fixed it.

Incidentally, I noticed just now that if you open an .asm file into MPLAB, Configure->Configuration Bits won't have settings that match the .asm code. However, if you import the .hex for the same code, the configuration bits will change to represent their status in the .hex when it was loaded, even if the "configuration bits set in code" box was checked.
 
Now I remember. When I try to program the 16F88 I get this warning:
ICDWarn0033: MPLAB ICD 2 does not support programming this device if both the internal oscillator and internal MCLR are selected. You may continue programming, but you are encouraged to cancel, reconfigure your device, and try again.
I don't know what will happen if I continue programming with both internal oscillator and internal MCLR. Any guesses?
 
You may not be able to reprogram it, as the internal oscillator is running and the VPP might not be able to get the chip into programming mode (since MCLR is now an input).
 
Hank Fletcher said:
Incidentally, I noticed just now that if you open an .asm file into MPLAB, Configure->Configuration Bits won't have settings that match the .asm code.
However, if you assemble (project->build all) the code, then "Configure->Configuration Bits" will match the .asm code.
As for the MCLR pin, one advantage of using a pullup resistor instead of directly tying it to Vdd is that you can do in circuit programming/debugging.
 
Omar.M said:
The MCLR pin is the reset pin for the microcontroller.
It is used to reset out of things such as interrupt routines, during PIC sleeping, and out of watchdog timer when it kicks in. It also resets the microcontroller's memory locations of the PIC-- thus needed for when you are ready to program the chip (programmer takes care of it).

Generally, you tie it through a resistor to VDD in order to keep it from accidentally resetting. The resistor is usually 10K ohms.

If you're not really needing to use it, I'd suggest turning it off. Else, tie to VDD to ensure you don't reset accidentally.
-Omar

OK most of this is incorrect. You don't use it to exit an ISR. MCLR resets most of the chip's features and starts the code from the base address. It will cancel Sleep mode, but that might be an odd thing to do since it'll reset the entire chip- usually you'd hook that wire up to an "external interrupt pin" (RB0) which will cancel Sleep mode and the code will simply resume at the next code line after Sleep. It is essential to reset one way or another when powering up, and often users want to be able to press a reset button.

In *most* cases you want MCLR on a pin pulled up with a 10K resistor. Most people do that for MCLR. There are numerous issues to doing it other ways, some big, some small. For one, without a 10k resistor you can't program it in-circuit through the usual procedure. If you try to use MCLR for something else and disable "MCLR on pin", then usually you can't use the normal programming procedure. It's a long story really. My advice, do NOT tie directly to Vdd without a resistor or use that "internal MCLR" feature unless you have a specific reason to do so and understand the issues involved. It can create a lot of headaches to save one 10k resistor.
 
Regardless of how it's pulled up (internal or external resistor) it's also usually wise to use a bypass capacitor between reset and ground (small value electrolytics or high value ceramics work well) which can prevent all but the most hardy of pulldowns from triggering a reset when you don't want one. Especially with high value pullups accidental resets from noise because much more common.
 
Sceadwian said:
Regardless of how it's pulled up (internal or external resistor) it's also usually wise to use a bypass capacitor between reset and ground.

Sorry, but complete nonsense! - if you select the internal pullup then the I/O pin isn't even connected to reset, it's a completely normal I/O pin - that's the entire point of it.

The MCLR/Reset pin on a PIC is very well tried and tested - if you want an external reset switch, then use a pullup resistor on the pin - if you don't want a reset switch, then wire the MCLR pin directly to Vdd, there's no need for any components at all.
 
Nigel Goodwin said:
if you don't want a reset switch, then wire the MCLR pin directly to Vdd, there's no need for any components at all.
Isn't the MCLR line pulled low by ICSP programmers/debuggers? Wouldn't that make a short between Vdd and Vss if there's no pull up resistor?
 
toodles said:
Isn't the MCLR line pulled low by ICSP programmers/debuggers? Wouldn't that make a short between Vdd and Vss if there's no pull up resistor?

If you strap MCLR high then you can't use ICSP, but we're not really talking about doing that, just about using the internal MCLR connection, freeing up the MCLR pin as an extra I/O pin. In which case, as long as your ICSP and your target circuit are suitably designed, then there's no problem reprogramming it.

However, it's essential that you can switch Vdd from the programmer, otherwise you can't enter programming mode.

Simple answer though! - don't use ICSP.
 
I have strap the MCLR high via a diode and the ICSP programming line connected MCLR pin.
 
toodles said:
Isn't the MCLR line pulled low by ICSP programmers/debuggers? Wouldn't that make a short between Vdd and Vss if there's no pull up resistor?

It's pulled to a special high voltage high- way above 5v- for programming. If in-circuit, we put a 10k resistor in there so the pin can be pulled up to what- 12V- so only 0.7mA of current pulling up the 5v rail which won't be enough to either load down the high voltage source or pull up the 5v rail.

You omit that 10k, the programmer's MCLR pin goes straight to the 5V rail and it could raise the Vdd voltage and cause a latchup or magic smoke, but generally programmers are made so the MCLR can only put out a few mA at most and thus usually the hv source will drag down before dragging the Vdd up. So, no ICSP without a resistor!

Usually when we disable "MCLR on pin", it's because we're out of pins and need to use the MCLR pin for something else. Well, we make MCLR an output to an LCD's data bus, holy cow when I put on an ICSP cable I'm putting 12V on that pin which is still wired to the LCD which tolerates 5v tops. It'll damage the LCD, I can never do ICSP with this. Or say I've got an external ADC chip and hook up its SDO to the MCLR, so MCLR is an input. Guess what, that 5v ADC isn't going to appreciate 12V applied to its output either, that's a limitation many people may not realize at first. Anyhow the ADC will probably be trying to drive the line to 0v or 5v any time it's powered up, won't work with ICSP, or maybe you can ensure it's in tristate (SPI can usually be disabled to tristate) but the presence of 12V on the ADC output is probably gonna damage the ADC.

On the other hand, maybe I'm gonna hook up a user's button (not a reset button)- the pin has a 10k pullup and pressing the button grounds it. Look here- that's sweet! As long as the button isn't pressed during programming this IS compatible with ICSP.
 
If you look at the data sheet for a PIC such as the 16F84, Microchip recommend that the reset be via a resistor in the range 50 to 100 Ohm to prevent the possibility of a latch up.

So I use a 68 Ohm in series with MCLR with a 10 k to Vcc. It does not matter which side of the the 68 Ohm you connect the 10 k.
 
That 50-100:eek:hm: resistor was only needed if you also had a capacitor connected to extend the reset time at power up. It prevented high currents from flowing into the pin on power down if Vdd was pulled down by another load on the 5V line. The other scenario is if MCLR has the potential to go below Vss. Some PICs mention this in their datasheet, and others do not. No harm in being prudent though.
 
Last edited:
So for turning the MCLR into an I/O we use __CONFIG MCLR_OFF? Dumb question, but I cannot find documentation on what these damn commands all do. I could not find any documentation in the help files or MPASM directories that describe what each of the __CONFIG commands do. Where are you guys finding it?
 
Last edited:
ljcox said:
If you look at the data sheet for a PIC such as the 16F84, Microchip recommend that the reset be via a resistor in the range 50 to 100 Ohm to prevent the possibility of a latch up.

That's an antique low spec PIC from the last century!, there have probably been no such recommendations for almost ten years?.
 
Ambient said:
So for turning the MCLR into an I/O we use __CONFIG MCLR_OFF?
The correct label depends on the particular device you're using. For most recent devices it's _MCLRE_OFF because of a terminology change.

Ambient said:
I could not find any documentation in the help files or MPASM directories that describe what each of the __CONFIG commands do. Where are you guys finding it?
IIRC there is a tutorial on microchip.com. I'll let you know if I'll find the link.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top