[SOLVED] programming error at address PicKit2

Status
Not open for further replies.

embpic

Advanced Member level 3
Joined
May 29, 2013
Messages
742
Helped
80
Reputation
160
Reaction score
77
Trophy points
1,308
Location
india
Visit site
Activity points
5,213
this is my first time of using pickit2. I have written simple LED blinking code.
i am using XC compiler and PIC16f876a controller.
I am getting problem while buring hex file using pickit2.


This error cause at starting after loading hex file and press WRITE button.



This error comes after press ERASE after that press WRITE button.

why this error is comes.
my code is

Code:
#include<xc.h>

//#pragma config WDT=ON
#pragma config CP=OFF
#pragma config LVP=ON
#pragma config BOREN=ON
#pragma config FOSC=XT

#define _XTAL_FREQ 12000000


void main(void)
{
    TRISB = 0x00;
    PORTB = 0x00;
    while(1)
    {
        PORTB = 0x55;
        __delay_ms(1);
        PORTB = 0xAA;
        __delay_ms(1);
    }
}
 

are you powering the PIC mcu with PIC kit only ?,

If yes There may be a chance that you should try with clicking on
the two Options
HTML:
"Vdd PICKit2"
ON[]  == Click on this 
MCLR []== Click on this
& Give 5V as "2.5V" is written there as per the image uploaded
 

yes i solve this problem but program run on software simulation but on hardware it is not running.
is this program is correct?
 

You might try changing the one millisecond delay to a duration perceivable by the human eye:

Code:
 __delay_ms(1);

To

Code:
 __delay_ms(500);


Also have you utilized a proper current limiting resistor in series with the LED?

Do you have proper bypass/decoupling capacitors across the VDD and VSS pins?


BigDog
 

this is simple sch i have implemented.
 

Attachments

  • sch.PNG
    37.1 KB · Views: 126

Where is the LED and its series current limiting resistor, typically 330Ω?

You should always employ bypass/decoupling capacitors, typical value 100nF, attached as close as possible to the VDD or VCC pins to the VSS (GND) pins.

BigDog
 

led resistor is 220 ohm and also put 0.1 uf capacitor between vss and vdd. but same result.
 

Disable the watchdog timer:

Code:
#pragma config WDT=OFF

Did you increase the delays?

Which PORT pin is the LED connected?

Also did you run a Verify to ensure the device was properly programmed?


BigDog
 

yes sir i have disabled WDT.
i have connected LED to portB.
and also varify the program.

Code:
#include<xc.h>

#pragma config CP=OFF
#pragma config LVP=ON
#pragma config BOREN=OFF
#pragma config FOSC=XT

#define _XTAL_FREQ 12000000


void main(void)
{
   TRISB = 0x00;
   PORTB = 0x55;
   while(1);
}
 

How do you have the Pickit connected to the PIC? I suspect the LVP is the problem, if you are using a connection to MCLR you may want to try turning LVP off or the PIC may be stuck in programmng mode.

You could also try setting the oscillator to HS mode.

Brian.
 
Reactions: embpic

    embpic

    Points: 2
    Helpful Answer Positive Rating
thank you sir LVP is OFF and XTAL change to HS mode and program work.
but what is reason for this change please explain.

- - - Updated - - -

if i keep config as then pickit2 gives error as
Code:
#pragma config LVP=OFF
#pragma config FOSC=XT
it gives error as unsupported part (ID=3FE0)

and if keep config as
Code:
#pragma config LVP=OFF
#pragma config FOSC=HS

then it load successful.
 

In LVP mode there is no need to supply a high voltage to the MCLR pin to start a programming cycle but you sacrifice one of the pins to be able to do it. The pin for LVP becomes the "programming mode / running mode" selector. If left disconnected it will be at an unpredictable voltage and could well leave the PIC in programming mode where it cannot run your code. When you set the LVP=OFF it makes the pin work as a normal input/output pin like the rest of them.

The OSC selection configures the gain and feedback between the PICs oscillator pins. At different frequencies you need different gains to make the oscillator run properly. In RC mode it has low gain and the circuit is configured to charge and discharge a capacitor connected to ground, in LP mode the drive level to the crystal is very low as you would use for small low frequency crystals (example: a 32KHz wristwatch crystal), XT mode is for medium frequency crystals and HS is for high frequency crystals.
There is no fixed boundary between the LP, XT and HS modes, they overlap to some extent. I would suggest the ranges are LP up to 500KHz, XT between 400KHz and 6MHz and HS for 5MHz and above.

Brian.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…