MCLR and PICK

Discussion in 'Embedded Systems and Microcontrollers' started by blah2222, Jul 6, 2011.

  1. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    554
    33
    Hello, I have been using the PICKIT3 and I have come across this little subtlety of the MCLRE configuration for the demo lessons.

    I have the PIC18F45K20 44pin demo board and have noticed that for all the demos, I have to TURN OFF the MCLRE configuration for my board to work. MPLAB says that it programs but no LEDs light up until I make sure that MCLRE is OFF.

    If you wouldn't mind, I would just like to have a better explanation of what is going on when the MCLRE config is ON. The datasheet says that when MCLRE is '0' (OFF) then the pin acts as a digital input (only). It also mentioned something about a POWER-ON RESET and High voltage programming... Don't really know what that is about.

    It seems that the board gets programmed in both cases of MCLRE being ON or OFF, but when it is ON ('1'), the board does not get power from the programmer? Is that correct?

    The programmer has the both a MCLR'/Vpp (pin 1), Vdd_tgt (pin 2), and LowVoltageProgramming (pin 6). What is the difference between these?

    Any advice on this would be great. Thanks!
     
  2. Barnaby Walters

    Member

    Mar 2, 2011
    103
    4
    Hi there,

    I'm probably not as well qualified as others here to answer you, but I'll give it a go. In 'high voltage' programming mode (default for most PICs) the MCLR pin must be bought high, around 12v, in order for the PIC to be programmed. Vpp (programming voltage) refers to this. Vdd is the power supply for the PIC.

    Low voltage programming enables some models of PIC to be programmed without this 12v signal, but I don't know anything about it.

    By MCLRE you mean MCLR reset enable? If you enable this, then if during program execution the MCLR pin is bought low (indicated by the bar above it's name) the PIC will halt program execution, and reset from the beginning.

    So, roughly: During programming, Pin 1 of the PK3 is brought to ~12v, enabling the PIC to have a program loaded into it's memory.

    During execution, the MCLR pin is either a digital input or an external reset as detailed above (note that it cannot be made an input), depending on the configuration settings you specify.

    Does that clear things up?

    Thanks,
    Barnaby
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    That's a pretty good description Barnaby (but excuse me while I blab on anyway).

    Ummm... close. The board may be programmed with the config bit for MCLR either state as this pin has a different function when you are programming or when you are running. "MCLR" (Master CLeaR) is the run time function, and Vpp (Voltage programming power) when ,well, programming.

    Now when your program is running the config bit for MCLR will allow you to either use the pin as a clear or as another input.

    The board gets its power from the Vdd_tgt pin (see below), not MCLR.

    The difference between individual pins is is nominally 0.1 inches. :D

    Here's what they do:

    MCLR/Vpp is as we've been describing.

    Vdd_tgt is short for "Power voltage for the target," where the target is what PIC is being programmed. It's the voltage to turn the PIC on while programming, but can also be used for debugging or just running the thing.

    LowVoltageProgramming is a logic level signal to inform the PIC it is being programmed, and is needed since in low v programming the MCLR signal doesn't rise above Vdd so the PIC needs some sort of signal to indicate when it is being programmed.
     
  4. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    554
    33
    *Pin 1 (MCLR') - Runtime

    - when this is enabled and it is between 1.8 - 14 V, the program resets and starts from the beginning of the file again, during runtime.

    *Pin 1 (Vpp) - Programming

    - ...still unclear of what this does during the programming process.

    Pin 2 (Vdd_TGT)

    - provides power from the programmer to the target board, (3.00 - 3.50 V).

    Pin 3 (GND)

    - ground reference.

    Pin 4 (PGD)

    - ISCPDAT, standard COM data

    Pin 5 (PGC)

    - ISCPCLK, standard COM clock

    Pin 6 (LVP)

    - low voltage programming... I don't know what this means (below):

    I appreciate the help!
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605

    Vpp is programming voltage, which is VDD + 4.5 volts (9V max) for this device. In the bad old days PICs had EPROM (one "E") that needed to be erased by UV light (if you bought the expensive "windowed" version that literally had a quartz window). To program these you needed a high voltage to set a voltage.

    As PICs advanced to the wonderful EEPROM (two E's are much better then one) the voltage wasn't needed to do the programming, but was grandfathered in as it was a convenient flag to let the PIC know it should work in programming mode. All the voltage did was trip a comparator bit so that THREE functions could be served by 1 pin (logic low, logic hi, and programming enable). That's why it is the MCLR/VPP pin.

    As things progressed it became apparent that some users would appreciate NOT having to make a higher then Vdd voltage just as a flag signal, thus the Low Voltage Programming pin was added. But, this needs to tie up a precious pin just to do programming, so both options are included: High voltage programming using MCLR/VPP, and low voltage programming using the LVP pin.

    A brand new PIC has both programming modes enabled. High voltage programming is always enabled, you can program the device to shut off low voltage programming and gain back 1 more pin.

    Do have a look at section 23.5 of the data sheet for this device.

    Do read the whole thing, some features interact with other features. You ain't gonna remember it all but you need at least 1 brain cell to fire so you go back and look when something comes up. :rolleyes:
     
Loading...