Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How should the MCLR pin of a PIC18 be set ?

Status
Not open for further replies.

Neyolight

Full Member level 5
Joined
Aug 29, 2011
Messages
306
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
World
Activity points
3,624
Heya

Well I have been reading a lot about MCLR/Vpp pin on a PIC18F and how it may cause some code to not work.

What should the normal TRIS bit for MCLR be? 1 or 0?

Cheers
 

First, I would say, "read the datasheet' for the specific PIC you have in mind.

Most of the 18F PIC's I use cannot make use of the MCLR pin as I/O, so there is nothing to set.

Some though (like the 18F45K22) share it with an input-only pin (RE3). In that case, the datasheet says that the pin does not have a TRIS or LAT register bit associated with the pin, since if it is selected as in input pin (by setting MCLRE=0) then input is all it can do. So, you just read it. No TRIS to set.
 
Heya

Well I have been reading a lot about MCLR/Vpp pin on a PIC18F and how it may cause some code to not work.

What should the normal TRIS bit for MCLR be? 1 or 0?

Cheers

MCLR/VPP:

--MCLR and VPP are two functions on the same pin;
--MCLR means Master Clear, and functions as the Reset pin on the PIC micro, causing the PIC to be held in a reset state as long as MCLR is at 0 volts.
When MCLR is connect to VDD instead, then the PIC begins running by executing the first instruction in program memory. (Note: Some PICs with built in calibratible oscillators may actually start at the very last address in program memory, which may be a MOVLW XX then wrap around to the first address where the user can, if they wish, put the MOVWF OSCAL so the part runs at it's calibrated frequency.)

--VPP means Voltage for Programming or something like that. When there are 9-12v (See specific datasheet) on this pin, the PIC goes into a special reset state where it's not running, but it can be programmed.



First, I would say, "read the datasheet' for the specific PIC you have in mind.

Most of the 18F PIC's I use cannot make use of the MCLR pin as I/O, so there is nothing to set.

Some though (like the 18F45K22) share it with an input-only pin (RE3). In that case, the datasheet says that the pin does not have a TRIS or LAT register bit associated with the pin, since if it is selected as in input pin (by setting MCLRE=0) then input is all it can do. So, you just read it. No TRIS to set.

Here is another trick, you can connect one of I/O pins to the MLCR and execute reset that way. You can perform reset action using your code.

For PIC18F devices,the RESET command actually generates a true RESET via the RESET instruction (same as MCLR). Other than tying a port pin to MCLR, a true RESET is not possible in firmware on PIC16F87XA devices. Although the RESET command is supported, it only causes the PIC16F device to jump to the RESET vector; the registers used to perform bootload operations are not changed to their RESET states.

Hope this may help you.
Thanks
 
Here is another trick, you can connect one of I/O pins to the MLCR and execute reset that way. You can perform reset action using your code.

That works, but might cause an issue if ICSP is used and the pin is taken to VPP. That should be taken account of in the circuit.
 
Hi,

I find it useful to always try and leave Mclre, PGD and PDC (rb6/7) clear of any standard i/o functions so you can dedicate them to icsp and debugger functions.
 

So, the tris bit for MCLR should always be 1 ?
 

So, the tris bit for MCLR should always be 1 ?

Hi,

When your Config is MCLRE=OFF then the power on default and all reset conditions return RE0 and all other ports as Input anyway.

Oops - meant RE3 !
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top