16f628a programming

Status
Not open for further replies.

trojan89

New Member
Could someone please tell me step by step how to program an 16f628a pic using a pic kit2 and icsp programming.
And i also need to set my pc to 00. How would i go about doing that.
When i have tried to program the pic it says programming failed at program mem address at 0x0000. what could i be doing wrong?
Thanks in advance
 
The PC starts at 00 on any reset so generally you don't need to set it there. If you want to go to the start again during the program, just write:

Code:
      goto   0

You can make that a bit more friendly by putting a label at the start of the code, for instance "start" and then writing


Code:
      goto   start

For the actual programming, you need to connect Reset, Vcc, Gnd, ISCP clock and ISCP data from the Pickit2 to the corresponding pins on the 16F628A. You do not need anything else. I mean no other components connected anywhere. You can use 5 short bits of wire poked into the socket int he Pickit2. You should make sure that works before trying programming in your circuit.

There can be a problem if you have configured that 16F628A to have both internal reset and internal RC clock. You should avoid having both of those together.
 
I have that problem with the PIC16F627/8 when I forget to ground pin 10 (RB4-LVP). Ground pin 10, double check your ICSP connections and make sure you've properly selected powered target vs non.
 
Last edited:
This is the program i am currently using. I have simulated it oshon software. Is there anything wrong with the program
; Begin
R0L EQU 0x20
R0H EQU 0x21
R1L EQU 0x22
R1H EQU 0x23
R2L EQU 0x24
R2H EQU 0x25
R3L EQU 0x26
R3H EQU 0x27
R4L EQU 0x28
R4H EQU 0x29
R5L EQU 0x2A
R5H EQU 0x2B
ORG 0x0000
BCF PCLATH,3
BCF PCLATH,4
GOTO L0002
ORG 0x0004
RETFIE
L0002:
; 1: Symbol comp_change = PIR1.CMIF 'comparator interrupt flag
; The address of 'comp_change' is 0xC,6
; 2:
; 3: CMCON = 0x06 'set comparator mode to two common reference comparators with outputs
MOVLW 0x06
MOVWF 0x1F
; 4: TRISA = 0x07 'set RA0, RA1 and RA2 as inputs, other PORTA pins as outputs
BSF STATUS,RP0
MOVLW 0x07
MOVWF 0x05
BCF STATUS,RP0
; 5: VRCON = 0xec 'turn on, configure voltage reference module for 2.5V and connect it to RA2
BSF STATUS,RP0
MOVLW 0xEC
MOVWF 0x1F
BCF STATUS,RP0
; 6: TRISB = 0x00 'set PORTB pins as outputs
BSF STATUS,RP0
CLRF 0x06
BCF STATUS,RP0
; 7:
; 8: loop1:
L0001:
; 9: While Not comp_change 'wait for comparator output change
L0003:
 
I have that problem with the PIC16F627/8 when I forget to ground pin 10 (RB4-LVP). Ground pin 10, double check your ICSP connections and make sure you've properly selected powered target vs non.
I grounded rb4(pgm). and i still get the same error. pic kit 2 still says programming failed at address 0x0000
 

I have connected the corresponding pins as given in pic kit 2 pdf. but i still get the same error. Do i have to make any additional connections?
 
And when i read from the pic, pickit2 says both code and data are protected. Does that have anything to do with this?
And the weird thing is it is reading from the pic. All program mem adressses are set to 3fff.
 
Last edited:
Have you programmed the chip before? If the code protect bits have been set you must perform a "Bulk Erase" to clear them.
 
Have you programmed the chip before? If the code protect bits have been set you must perform a "Bulk Erase" to clear them.

How do i perform the bulk erase operation? PICkit 2 says it performs the bulk erase operation before writing the program.
 
That's it, you're already doing it. I wasn't sure if you had perhaps disabled that typically default behavior. Is your circuit self powered or powered through the PicKit2? What's the current draw?
 
That's it, you're already doing it. I wasn't sure if you had perhaps disabled that typically default behavior. Is your circuit self powered or powered through the PicKit2? What's the current draw?
I am powering it through pickit 2. Not sure bout the current draw(havent measured it)
 
When the 16F628A is erased, all the lines will read 0x3FFF.

The actual code you are writing doesn't matter at all when programming with the pickit2. In the pickit2 software, you can erase the 16F628A, set a few lines to something that isn't 0x3FFF, and click on "write". That should be enough. If you read it back, it should be the same.

Once that works, add your code.

Have you just got the 5 pins you need on the pickit2 connected to the 5 pins of the 16F628A? You don't need anything else.
 

Thank you, but any time i try to program anything it says programming failed at program address 0x0000. I have connected the five pins of pickit2 to their corresponding pins. still doesn't work
 
I have a poster on my site that will work for a PICKit2 called Inchworm quick start. It shows the proper connection from an ICD to a handful of popular pics.
 
1. Do you have any circuitry connected to the micro?
2. Does PICKit-2 recognise the chip?

I had circuitry wired first but have tried to connect directly from pickit 2 now.
I have pic kit2 on manual select mode because 16f628a doesnt have auto detect( or that is what the manual says)
 
it could be your chip is bad but you would of had to really neglect it. PICs are fairly tough. Are you connecting the programmer with jumpers and a solderless breadboard? Soldered breadboard? Header on PCB? Do your jumpers have breaks hidden by wire insulation? You tried with nothing more than the PIC, PICKit2 and the five ICSP connections? How long are the ICSP jumper wires? Do you have the PIC inserted backwards? Do you have the PICKit2 backwards? Are you confusing Vdd and Vss? What software are you using to program the PIC? Are you using a modern computer? Does your USB port support the full current/voltage spec? Is it a laptop? If so is it running on batteries or plugged in? .... Check everything.
 

Using a breadboard (solderless)
No jumpers
Yes i have tried nothing but PIC, PICkit2 and 5 icsp connections
icsp lines are about 7cm long
NO double and triples checked pin connections along with Vdd and Vss.
Using PICkit 2 V2.61 to program. Yes am using a modern computer. I have tried programming it both on a laptop and a desktop(neither works).
 
i noticed that you refer the 628 and 628a in your posts.
please check that you are using a 628a device.
627 and 628 cannot be programmed with the pickit2.
in mplab, go to configuration>Select device. select the 16F628 and see that the pickit2 check box goes red.

hope i could help.
Best regards,
ameal
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…