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.

Can't Reprogram PIC16F628A with Pickit2

Status
Not open for further replies.

capitanui

Newbie level 5
Joined
Dec 22, 2010
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,382
Hy guys,

I'm new to this forum and to picmicro also..and i believe i made a mistake and now i don't know how to solve it.. I programmed a pic16f628a with configuration word like below:

__CONFIG _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _BODEN_ON & _LVP_OFF & _CP_OFF & _MCLRE_OFF

And now my code is executing normally but my pic won't enter again in programming mode...I believe this is because i disabled MCLR..I searched for other threads on this forum and others but nothing..someone told my i can try LVP and pull RB5/PGM to ground...but since LVP is disabled also..i believe this won't work..
Is there someone that can help with this kind of problem? Thanks In advance!
 

I think you need to use high voltage program mode, but I am not sure. It depends on your programmer as to whether you can do that.

https://ww1.microchip.com/downloads/en/DeviceDoc/41196g.pdf

Keith.

---------- Post added at 11:21 ---------- Previous post was at 11:18 ----------

This also suggests that a high voltage is needed for programming:

https://ww1.microchip.com/downloads/en/DeviceDoc/30610c.pdf

---------- Post added at 11:29 ---------- Previous post was at 11:21 ----------

And a bit of info here: pic16f628: can't use MCLR pin for I/0!
 
Last edited:

I use Pickit2 for programming...i did more reading and it seems its a problem with 18 pin devices when MCLR is OFF and the internal osc is used...and this is exactly my issue...it seems that the device goes directly into executing mode when VDD is applied ...because there is no time vor VPP to rise at VIHH level..and PCL is incremented...when VPP rise to the correct level the programming won't work because PCL is pointing something else than 0x00...

I am begineer but hope i understand what i read so far...seems this can be resolved by minimizing the VDD on pickit2 software, or use option "Use VPP First Programming"...i will try this when i will get at home at my development desk...i will come back with the result...if this worked than maybe it will help someone else..if not maybe i will find another solution!

Thanks for you reply ..
 

you have to use Vpp first mode in case of internal osc and mclr off
Otherwise, immediately as Vdd is given , the circuit starts and you cant reach programming mode. You may click "tools" in pickit2 driver and Use Vpp first program entry. Erase once what you had loaded and load afresh
 

Hi,

Yes, the 628As do seem to have strange programing problems that I have not experienced with other 16F or 18F chips.

Your Config looks normal and should not cause any problems.

You do not say how you are programming your 628A, is it in a dedicated programing socket or are you doing it in circuit ICSP?

If its ICSP you must have the circuitry as shown in the ICSP section of the PK2 manual.

For either, ensure the cable length from the PK2s output to the 628A is as short as possible - just a few cm / inches.

Pulling the LVP pin to ground will not harm anything, though it should not be needed with the PK2.

Edit - seems like MVS has located the problem - you have to use Vpp first mode in case of internal osc and mclr off
 

I tried everything....Use Vpp first and all that..but it still broken...i dnon't know what to do...since i wrote that program it isn't recognized by the programmer...but the program executes on it...
If anyone else has an ideea please reply..i will post also the program wich i last written in it ...maybe it will help..

LIST P=16F628
#include "P16F628.INC" ; Include header file
__CONFIG _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _BODEN_ON & _LVP_OFF & _CP_OFF & _MCLRE_OFF

;------------------------------------------------------------
cblock 0x20 ; Beginn General Purpose-Register
;-------------------------- counters
count1
count2
count3
;--------------------------
endc
;--------------------------
#DEFINE pwmu PORTB,3
;--- Reset --------------------------------------------------
org h'00'
goto init ; reset -> init
;--- Interrupt ----------------------------------------------
org h'04'
;--------------------------
init clrf PORTA
clrf PORTB
movlw 0x07 ; Turn comparators off and enable pins for I/O
movwf CMCON
bcf STATUS,RP1
call usi ; port settings
call pause
movlw 0xFF
movwf PORTB
call pause ; wait 126ms
call set_timer

;--------------------------
uu
call pause
movlw 0x02 ; set pwm at 2/256
movwf CCPR1L
call pause ; wait 126ms
movlw 0x10
movwf CCPR1L ; set pwm at 10/256
call pause
movlw 0x40
movwf CCPR1L
call pause
movlw 0x80
movwf CCPR1L
call pause
movlw 0xFF ; max. power
movwf CCPR1L
call pause
movlw 0x80
movwf CCPR1L
call pause
movlw 0x40
movwf CCPR1L
call pause
movlw 0x10
movwf CCPR1L
goto uu ; repeat

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set_timer
clrf T2CON
clrf TMR2
clrf INTCON
bsf STATUS,RP0
clrf PIE1
bcf STATUS,RP0
clrf PIR1
bsf STATUS,RP0
movlw 0xFF
movwf PR2 ; compare with 255
bcf STATUS,RP0
movlw 0x02
movwf CCPR1L
movlw 0x03
movwf T2CON ; prescaler 1:16 and postscaler 1:1
movlw 0x3C
movwf CCP1CON
bsf T2CON,TMR2ON ;turn on timer, see pic16f628 datasheet
return

;************************************************************************
; Delay *
;************************************************************************
pause movlw 0x02 ;126 ms
movwf count3
d3 movlw 0x3F ;63 ms
movwf count1
d1 movlw 0xFA ; 1ms
movwf count2
d2 nop
decfsz count2,F
goto d2
decfsz count1,F
goto d1
decfsz count3,F
goto d3
retlw 0x00
;============================================================
usi bsf STATUS,RP0 ; Bank 1
movlw 0xFF ; all input
movwf TRISA
movlw 0x00
movwf TRISB ; all output
bcf STATUS,RP0 ; Bank 0
return
;============================================================
end
;============================================================

---------- Post added at 13:48 ---------- Previous post was at 13:30 ----------

I also tried this:


[qoute]
The problem occurs when the device is programmed so that:
1) It uses the internal oscillator
-and-
2) The MCLR pin is turned off to use as a digital input instead
-and-
3) The program code enabled the Timer1 Oscillator in the T1CON register. (The sooner this is enabled after the reset vector the more likely the problem is to occur.

This problem can be prevented by avoiding one of the 3 conditions above.

It is possible to recover parts with this issue. To do so, follow these steps in the PICkit 2 Programmer software:

A) Put the part on a breadboard or other jig where it is only connected to the 5 PICkit 2 programming signals.
B) Open the PICkit 2 Programmer application v2.40 (or later). Select "Device Family > Midrange"
C) Set the PICkit 2 Programmer VDD voltage box to 3.0 Volts
D) Select "Device Family > Midrange" again; it should now detect the part
E) If the part is not detected in D), reduce the VDD by 0.1 volts and try again. Repeat until the part is detected.
F) Select the WRITE button. It should now erase the part. [/qoute]
 

Hi,

First a couple of questions to you -

1. What physical chip are you actually programming, is it a 628 or a 628A ?

2. Your post heading states 628A yet the code you just posted refers is LIST and Including the 628 - there are slight differences.

3. Your programmer -is it a genuine Microchip unit, a purchased clone or a diy clone ?

4. When you program the chip, is it in a dedicated socket or is it mounted in the working circuit ?


I have built your code and done some tests.....
 

1.628A
2.programmer is a pickit2 clone..but i can reprogram another part without problems...prog from sureeectronics.com
3. i tried in a dedicated circuit...i tried in circuit... a way or another if i put another part it has no probl seeing it...no matter the circuit...
4 the code is working on it...if i connect a led on rb3 i can see it fade in/out

Thanks for your reply..
 

Hi,

Well there are some supple differences between the two chips, you can check on them in this document.
https://ww1.microchip.com/downloads/en/DeviceDoc/40048a.pdf

I built your code as it stated a 628 and programmed it into a 628 chip in its own dedicated socket with just the 5 pickit2 connections.

That worked ok, I read the data back ok, reprogrammed it several times ok.
Programmed it with another larger different program ok, then with your program again a few more times, all ok.

No idea about running it from 3v etc, but think your problem may be the breadboard and the long wires used.

The 628 /628A chips do seem to have a lot of problems as covered in the Microchip forums, so if you are using breadboard and their relativley poor connections you will be compounding any problems.

Try using a new 18 pin dil socket and a new 6 way set of 0.1" pins and solder the two together with some thin wire keeping them under 3" long.
Then program your chip with that, ensuring that the program code and chip are the same, unlike now where you appear to be using 628 code into a 628A chip - there might not be a difference, but you don't know for sure ..?

Long term perhaps migrate away from them an use a better chip like the 16F88
 

I understand...i am a begineer and i am trying to learn...i indeed use a breadboard...but what i cannot explain myself is why i can program another chip....same model..with the same hardware..but not this one...it's for sure something with the program i wrote in it but even if i knew what i still don't have what to do know....

thanks for replys
 

Hi,

Well its always hard to say what someone elses problem is, software. hardware etc, sometimes you will spot the error, eventually, other times you just have to work around it.

Breadboards are popular but they are known to sometimes cause problems if they become worn and dusty, paticularly when programming micros and using crystals.
You said you have a Sure PK2 - did you but their matching ZiF programmer board with its 3 zif sockets -well worth it - got one myself.
 

yes..i also have ZiF programmer board with its 3 zif sockets ....i tried there also to program this chip..but nothing...i think that i will gave up...
i have a pic16f684.... i will begin to study it and learn on it...maybe it;s better
 

First of all, use power from the pickit2 and select Vpp first mode.
and erase the chip
then only anything else is possible
as a biginer, dont use Mclr_off
keep it ON and have a 10K resistor connected to Vdd
later after you gain experience you may try that
at the worst you loose one pin for your use.
 

Thanks for repply...i did all it takes to erase the chip but nothing seems to work...i spoke with some people where i work...and they said they a kind of "special programmer" that can erase almost all chips with any configuration ...i will try that but after the holidays...thanks again all for your repies
 

your Pickit2 might be having low Vpp. you have to configure Vdd and Vpp first
follow calibration and troubleshooting procedure many chips you can manage with pickit2 and surely 16F628A
otherwise the chip is lost
 

Yes..i do agree with MVS. Check the voltage of the Vpp which should'nt be lesser than 11.9V. This can easily tested by the Pickit2 software > Troubleshooting or measured by a Multimeter. Also verify the Vdd the nearest to 5.0 volts.
Cheers
 

i already verified the voltage levels...both with multimeter and software...vpp ~ 12.14 V, vdd ~ 4.76...around these values
 

as i told, ensure that the pic under program is powered by pickit2 and not from target board, and if you use Vpp first mode, you should be able to erase it.
 

I think this is another Microchip goofup. Even I can never ever get a 16F628A to reprogram using the PICKIT2/PICKIT3 and the given procedure.

I had a similar problem on even 18F1220.

regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top