PDA

View Full Version : reprogramming 16f676



scorpion
- 9th May 2005, 21:32
Hi i wrote a program for the 16f676 and programmed it (ICSP) onto my board. I had some timing issues so i reworked the program and now it wont program again. (I am using the EPIC programmer)
I thought it might be the chip or the programmer, so i tried another board. it programmed! but the timing still wasnt quite right. so i changed the program again, and this pic wont program. Its not an otp so.... any ideas????

mister_e
- 10th May 2005, 02:06
Have you try to erase the PIC before reprogram it? what is your actual clock speed? Can you send some snip or the whole code if somebody here can find something?

scorpion
- 10th May 2005, 16:25
hi,
i did try to erase it... many times.
i am using the internal rc osc.
and here is my code:

upin var porta.0
dwnin var porta.1
upout var porta.4
dwnout var portc.4
ledout var porta.5

adcon0 = 0
ansel = 0
cmcon = 7

onbit var bit
i var byte
onbit = 0

main:
if upin = 1 then
low dwnout
onbit = 0
high upout
endif
if upin = 0 then low upout
if dwnin = 1 then goto float
goto main





float:
if onbit = 1 then goto main

for i = 1 to 100
if dwnin = 0 then
low dwnout
goto main
endif
next i
onbit = 1
high dwnout
goto main

dont laugh at my code. im not a (very good) programmer.
any ideas?

Warrier
- 10th May 2005, 16:26
That's an interesting problem you have - I had a similar experience with 12F629 where the chip behaved properly if all my timing was using PAUSE but failed to reprogram when using the NAP in my code... Finally I ended up using the extended temperature version of the device (12F629E/P instead of the I/P) and haven't had any problems since!

I had to use NAP to keep power consumption low - do you have a similar situation?

-warrier

scorpion
- 10th May 2005, 16:30
no nap, no pause. thats my whole code, just a good old fashion for next loop

scorpion
- 10th May 2005, 16:47
i tried to erase it again. The epic says that erase sucessfull or something even if there is no chip in there, so i don know how well I can trust it. anyways. I tried to run it and it was deffenatly erased. the board does nothing now. and it still doesnt reprogram.

scorpion
- 10th May 2005, 22:19
ok so I found the problem.... its sleep. i think i need more.
apperently pics dont like 12 V on an input pin......

sorry to all 54 people who wasted their time reading this and to warrier and mr.e answering me.
Is there anyway this thread can be deleted to stop any more of my embarrassment?
-scorp

mister_e
- 11th May 2005, 00:16
hehe bah don't be shy, you can't imagine how many time it happen to everybody here one day or another. I'm sure you'll not redo the same error two times :)

Warrier
- 11th May 2005, 11:39
Actually you need a pat on your back! You solved a problem by yourself that we couldn't visualize just by reading your code - it's the best way to learn and don't be embarrassed. When dealing with peripherals sometimes it is a good thing to make sure one has a reasonable configurations - chips usually fail through hardware issues - but software often gets carries the blame....

-warrier