PDA

View Full Version : 16F676 programming problem



Christopher4187
- 18th May 2009, 02:42
I can't figure this one out.

I'm using a 16F676 with a simple blinking LED program.

Here is my code:

@ DEVICE PIC16F676, INTRC_OSC_NOCLKOUT,WDT_ON, PWRT_OFF, MCLR_OFF, BOD_ON,PROTECT_OFF

TRISA = %00000000
TRISC = %00000000
ANSEL = %00000000
WPUA = %00000000

START:
HIGH PORTC.4
PAUSE 1000
LOW PORTC.4
PAUSE 1OOO
GOTO START

Ok, so I program the chip and all works well. Then I adjust the code and I try to program it again after I modify the code (increasing the pause to pause 2000). Then part of the way through the programming it gives me a configuration error during programming. It fails the programming and then when I go to compile it again, it tells me that the target does not match the device or something like that and I can never program it again. However, the code works fine so I know the PIC is intact but I just can't program it again.

So, I change to a brand new chip and complete the process over again only to get the exact same results. I've done this with 10 chips and it's all the same.

What the heck is going on here??!! I've been using PIC's for the better part of four years and I've never had this problem. I tried two different versions of MELABS programmer but I still get the same thing. I'm using PBP 2.50 and MELABS programmer 4.01. I'm also using the ICSP as I've done many times before.

Any ideas?

ardhuru
- 18th May 2009, 09:58
I can't figure this one out.

I
@ DEVICE PIC16F676, INTRC_OSC_NOCLKOUT,WDT_ON, PWRT_OFF, MCLR_OFF, BOD_ON,PROTECT_OFF


Internal oscillator and Master clear off is a combination that often does this. You need to use a Vpp-before-Vdd option in your programming software, if it exists. That should cure it, and reclaim all those chips you've tried, which are currently not (re)programmable.

Regards,

Anand

ardhuru
- 18th May 2009, 10:01
Opps; forgot to mention, this wont work if you're using ICSP with an independent target supply. You'll need to put the chip in a socket / breadboard, and connect all ICSP signals *including* the switched Vdd from the programmer.

Anand

mister_e
- 18th May 2009, 17:39
Even if it never happened to me, I would bet on the MCLR_OFF. Some device programmer are a bit fussy on that. Seems Melabs don't recommend it on their website though.



3. Configure MCLR as a RESET pin if possible. The programmer will attempt to reset the target device at the beginning of the programming process. If the MCLR pin is configured as an input, the programmer may have problems putting the chip into program-mode. This is especially problematic if the target has been previously programmed and is using the programming clock or data lines as outputs.

In some situations, there just aren't enough pins to allow the use of a RESET. Your project will require that MCLR be used as an input. This is common on small, 8-pin PIC MCUs. In these cases, it helps to set the clock and data pins to inputs and place a delay at the beginning of your code. This will allow you to cycle power to the part and start the programming process while the pause is executing.

In a PICBASIC PRO program intended for the PIC12F675, you might start with:

TRISIO = $FF ' set all pins to inputs
PAUSE 1000 ' wait a second

This can make reprogramming much easier to accomplish when the programmer has no means to reset the target device