Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Programming problem with PIC16F628A!! Please HELP!

Status
Not open for further replies.

kteng

New Member
Hey Guys, i know this might be an old question in this forum but i just can't find any solutions to fix the problem. Here is the question:

First, I got my code built/make in MPLAB (IDE v8.76) with no errors, and I used the "MPLAB Compatible Mini USB PIC Programmer" from Cana kit to program PIC16F628A. When I first launch the PICKIT2 programmer in MPLAB, there was no problem at all (See Below):

"Found PICkit 2 - Operating System Version 2.32.0
PICkit 2 Unit ID = CANAKIT.COM
Target power not detected - Powering from PICkit 2 ( 5.00V)
PIC16F628A found (Rev 0x8)
PICkit 2 Ready"


However...When I tried to program the code into the chip..there was an error (See Below):

Programming Target (9/14/2011 9:18:58 AM)
PIC16F628A found (Rev 0x8)
Erasing Target
Programming Program Memory (0x0 - 0xA)
Programming Program Memory (0x19 - 0x7FF)
Verifying Program Memory (0x0 - 0xA)
PK2Error0027: Failed verify (Address = 0x0 - Expected Value 0x1068 - Value Read 0x3FFF)
PICkit 2 Ready


There is an error for Failed verify...and I'm not sure what I can do to fix this problem since I'm using the Cana kit programmer.

Another very interesting problem I found out is that after the failed verify error showed up and I opened up the standalone PICkit 2 v2.61 software and tried read the data from the chip...it shows that there was an Data Protect.

or If I use the standalone PICkit 2 v2.61 software to upload the HEX file into the Chip...it seems like the code was being uploaded to the chip with no errors, but when I took the chip out of the Cana kit and test it on breadboard, the chip was not doing what it suppose to.

I really need HELP guys...Thanks so MUCH!
Kevin
 
ok, couple of things to check, classics are LVP enable, make sure its disabled, the other is to make sure all write protection is disabled, if it enabled it will fail a verify as the code protection stops the ability to read the chip.
 
Where do I go to check to see "LVP" and "Write protection"?? sorry...I'm new to PIC. Thanks for the reply.
 
they will be in your fuse settings, or config settings, sorry i dont use MPlab

Yea i think LVP is off in the config settings.

Here is what I have in my config in the code:

include <p16f628.inc>
__config _HS_OSC & _WDT_ON & _LVP_OFF & _BODEN_ON & _MCLRE_ON & _PWRTE_ON
 
turn off the watchdog, power up timer, and brown out detect.


include <p16f628.inc>
__config _HS_OSC & _WDT_OFF & _LVP_OFF & _BODEN_OFF & _MCLRE_ON & _PWRTE_ OFF

This wont solve your write failures but its good to disable these until you have code that runs properly, then include these later.

do you have any settings for write protection?
 
turn off the watchdog, power up timer, and brown out detect.


include <p16f628.inc>
__config _HS_OSC & _WDT_OFF & _LVP_OFF & _BODEN_OFF & _MCLRE_ON & _PWRTE_ OFF

This wont solve your write failures but its good to disable these until you have code that runs properly, then include these later.

do you have any settings for write protection?


I don't think there is any write protection in the code, here is the code i'm trying to upload: http://memweb.newsguy.com/~rhuang/RFID/Reader_2.ASM
 
Better to add in the config '& _CP_OFF'
Later use trouble shoot and with a dmm measure the Vpp and Vdd voltages
you can set the Vdd for 4.8V or so and Vpp should be above 11V, precisely above 10.75V, as, many say

if the Vpp is less the program wont be loaded and you read 3FFF instead of what your hex says.
 
The USART TX isn't going to work. BOTH bits RB1 and RB2 (USART RX and TX respectively) must be set in TRISB in order for RB1/RX and RB2/TX to be tied to the USART. I know this goes against all logic as one would think that setting TRISB:RB2 to a 1 should make it an input and TX is an output, but the data sheet for the 16F628A states that BOTH TRISB:1 AND TRISB:2 must be set to tie these pins to the USART.

Find the line of code that states -

Code:
;*********************	Setting up environment
	movlw	b'10000010'		;Serial port in too
	movwf	TRISB			;Set port B I/O
	movlw	b'00000111'
	movwf	TRISA			;Set port A I/O
	bcf		STATUS, RP0
	clrf	PORTA

Change the first line of this code so that it reads -

Code:
;*********************	Setting up environment
	movlw	b'10000110'		;Serial port in too
	movwf	TRISB			;Set port B I/O
	movlw	b'00000111'
	movwf	TRISA			;Set port A I/O
	bcf		STATUS, RP0
	clrf	PORTA

Also, I would do this for the header information at the top of your code -

Code:
		list		p=16F628A, r=dec, w=-302
		include		<P16F628A.INC>
		__config	_LVP_OFF & _BOREN_OFF & _PWRTE_ON & _WDT_OFF & _HS_OSC
 
Last edited:
I tried to set the Vdd for 4.8V, but still can't get MPLAB to Vertify...same error as before:

Programming Target (9/15/2011 9:34:10 AM)
PIC16F628A found (Rev 0x8)
Erasing Target
Programming Program Memory (0x0 - 0xA)
Programming Program Memory (0x19 - 0x7FF)
Verifying Program Memory (0x0 - 0xA)
PK2Error0027: Failed verify (Address = 0x0 - Expected Value 0x1068 - Value Read 0x3FFF)
PICkit 2 Ready



However...if i program the hex file into the chip using PICkit2 standalone software, the hex file in the chip is able to read (see pic), but its not working correctly when connect the chip in a circuit (see 2nd pic for the circuit diagram i'm wiring up)

**broken link removed**

**broken link removed**

There was no 150khz square wave at PIN 9..just a constant DC voltage
Is it possible that my cana kit programmer is not working properly?

Thanks
 
you my have to ensure that the Vpp is not less than 10.75V DC as i told you
in general, I use picki2v2.61 driver
there we have a facility to trouble shoot the Vdd and Vpp voltages. During that time we can actually measure.at the iCSP pins. suppose you are programming insitu, then osc has to be disabled, and lots of UF caps to be removed. Instead, you may pull out the chip , if it is DIP and in a socket, and program independently.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top