Problem while flashing PIC Controller with PICKIT3

Thread Starter

ep.hobbyiest

Joined Aug 26, 2014
171
i am facing problem while programming PIC16F18875 using pickit3. I am using mplab x on windows 10. I bought new chip and and from first i am getting problem.
currently i am giving power from pickit3 which is approx, 4.5V.
I checked the connection for MCLR, VDD, VSS, PGD and PGC pin.
I have connected 0.1 uF capacitor between VSS and VDD.
Following is the code i was trying.
Code:
// CONFIG1
#pragma config FEXTOSC = OFF    // External Oscillator mode selection bits (Oscillator not enabled)
#pragma config RSTOSC = HFINT1  // Power-up default value for COSC bits (HFINTOSC (1MHz))
#pragma config CLKOUTEN = OFF   // Clock Out Enable bit (CLKOUT function is disabled; i/o or oscillator function on OSC2)
#pragma config CSWEN = ON       // Clock Switch Enable bit (Writing to NOSC and NDIV is allowed)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (FSCM timer disabled)

// CONFIG2
#pragma config MCLRE = ON       // Master Clear Enable bit (MCLR pin is Master Clear function)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config LPBOREN = OFF    // Low-Power BOR enable bit (ULPBOR disabled)
#pragma config BOREN = OFF      // Brown-out reset enable bits (Brown-out reset disabled)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (VBOR) set to 1.9V on LF, and 2.45V on F Devices)
#pragma config ZCD = OFF        // Zero-cross detect disable (Zero-cross detect circuit is disabled at POR.)
#pragma config PPS1WAY = ON     // Peripheral Pin Select one-way control (The PPSLOCK bit can be cleared and set only once in software)
#pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable bit (Stack Overflow or Underflow will cause a reset)

// CONFIG3
#pragma config WDTCPS = WDTCPS_31// WDT Period Select bits (Divider ratio 1:65536; software control of WDTPS)
#pragma config WDTE = OFF       // WDT operating mode (WDT Disabled, SWDTEN is ignored)
#pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
#pragma config WDTCCS = SC      // WDT input clock selector (Software Control)

// CONFIG4
#pragma config WRT = OFF        // UserNVM self-write protection bits (Write protection off)
#pragma config SCANE = available// Scanner Enable bit (Scanner module is available for use)
#pragma config LVP = ON         // Low Voltage Programming Enable bit (Low Voltage programming enabled. MCLR/Vpp pin function is MCLR.)

// CONFIG5
#pragma config CP = OFF         // UserNVM Program memory code protection bit (Program Memory code protection disabled)
#pragma config CPD = OFF        // DataNVM code protection bit (Data EEPROM code protection disabled)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.


#include <xc.h>

#define _XTAL_FREQ  4000000

void main(void) {
    OSCCON1 = 0x60;
    OSCFRQ = 0x02;
    
    ANSELC = 0X00;
    TRISC = 0X00;
  
    while(1)
    {
        LATCbits.LATC5 ^= 1;
        __delay_ms(1000);
    }
    return;
}
and Error i am getting as follows
Code:
*****************************************************

Connecting to MPLAB PICkit 3...

Currently loaded firmware on PICkit 3
Firmware Suite Version.....01.56.00
Firmware type..............Enhanced Midrange

Programmer to target power is enabled - VDD = 4.375000 volts.
Target Device ID (0x0) is an Invalid Device ID. Please check your connections to the Target Device.

Device Erased...

Programming...

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x7ff
configuration memory
program memory
Address: 0 Expected Value: 3180 Received Value: 0
Failed to program device
 

Thread Starter

ep.hobbyiest

Joined Aug 26, 2014
171
Very basic connection i have done. There is nothing connected to PGD and PGC. following is the MCLR connection,
1601792766034.png

And later i was giving the supply +5v from the battery then i am getting following error
(after connecting battery i disabled the option to power from pickit3)

Code:
PICkit 3 is trying to supply %f volts from the USB port, but the target VDD is measured to be %f volts. This could be due to the USB port power capabilities or the target circuitry affecting the measured VDD.

The target circuit may require more power than the debug tool can provide. An external power supply might be necessary.
Connection Failed.
 
Last edited:

AlbertHall

Joined Jun 4, 2014
10,536
With the pickit supplying power, set to 5V, measure the voltage between the supply pins of the chip, directly on the chip.
 

Thread Starter

ep.hobbyiest

Joined Aug 26, 2014
171
I have a doubt that PICKIT 3 is not supporting PIC16F18875. As this PIC controller newer AFAIK.
On the product page also it is not listing pickit 3 as a supporting debugger.
can anyone here confirm about the same?
 

AlbertHall

Joined Jun 4, 2014
10,536
In program files(x86) > microchip > V5.40 (or wahtever your version is) > docs > device support.html you will find a list of devices and tool support.
For V5.40 both programming and debugging are supported.
 

upand_at_them

Joined May 15, 2010
540
Where does that come from? I'm looking at the PICKit3 device file and it's not listed. Possibly only supported by MPLAB and not the standalone programming GUI?
 

Thread Starter

ep.hobbyiest

Joined Aug 26, 2014
171
i changed the board now atleast the error which were related to voltage level is gone.

Now i am getting error for LVP. This is brand new chip. here are the logs
Following error came when i change the configuration value as LVP=OFF. I changed the config setting in the Pickit3 configuration as well.
Project -> Set Configuration -> Customize ->Pickit3 -> program option.
here i untick the option for Use LVP mode entry.
Code:
/***************************************************/
The low voltage programming feature requires the LVP configuration bit to be enabled on the target device. Please enable this configuration bit and try the operation again.

****************************************************/
And following error came when i change the LVP = ON. and I changed the config setting in the Pickit3 configuration as well. Project -> Set Configuration -> Customize ->Pickit3 -> program option.
here i tick the option for Use LVP mode entry.
Code:
MPLAB X has detected that the device’s low voltage configuration bit is set to OFF but the tool is set to low voltage programming and cannot program the device. Please verify that the target device is attached to the debug tool. If the target device is attached, follow the instruction below to fix the problem.
1. Change the tool’s programming option to use High Voltage programming.
2. Change the device’s configuration bit to use low voltage (LVP=ON). Program the device using high voltage to reprogram the device’s configuration bit.
3. Change the tool’s programming option back to Low Voltage programming for subsequent programming of the device.
 

AlbertHall

Joined Jun 4, 2014
10,536
When you change a config setting in your program, it only changes the setting in the chip when it is programmed.

And following error came when i change the LVP = ON. and I changed the config setting in the Pickit3 configuration as well. Project -> Set Configuration -> Customize ->Pickit3 -> program option.
here i tick the option for Use LVP mode entry.
So if the chip has LVP OFF then it must be programmed the high voltage way. That program may set LVP ON and after that you can program it the low voltage way.
 

Thread Starter

ep.hobbyiest

Joined Aug 26, 2014
171
So if the chip has LVP OFF then it must be programmed the high voltage way. That program may set LVP ON and after that you can program it the low voltage way.
Okay. I have not set the LVP mode for PIC. and are you saying high voltage programming means ICSP?
How can i program it using high voltage?
AFAIK pickit3 flashes using high voltage by default and PIC also comes with by default ICSP high voltage mode.
 

jpanhalt

Joined Jan 18, 2008
10,463
All PIC LVP capable chips come with LVP as default. The reason is simple. If someone only had LVP equipment, they would never be able to program. However, once a user sets them to HVP (flips the LVP bit in the chip's configuration byte), then high voltage must be used to reset the chip back to LVP.

EDIT:
As for difficulties programming, I cannot be specific as I use an older version of Microchip's IDE. However two possibilities come to mind:
1) I set the device in two places: (1) As a directive in code; (2) In a configure setting for the programmer. The latter is required to program. The directive in code is an error check to remind me to do that.
2) If the connecting wires are too long you can get the error you describe. That can be a problem with PK3 as its power supply is very weak.
 
Last edited:

MrSalts

Joined Apr 2, 2020
40
You have a resistor and diode connected to the program pin, Vpp, and no path to ground. The diode is dropping the voltage and there is no path to ground ro release the programming voltage.

Get rid of the diode and connect as the datasheet recommends.
 

upand_at_them

Joined May 15, 2010
540
You have a resistor and diode connected to the program pin, Vpp, and no path to ground. The diode is dropping the voltage and there is no path to ground ro release the programming voltage.

Get rid of the diode and connect as the datasheet recommends.
The programmer controls the programming voltage. The diode prevents the programming voltage from overpowering the Vdd rail. I've used the same setup in post #5 many times. Microchip evens suggests that technique.
 
Top