2
\$\begingroup\$

OK, I have written a few basic programs in MPLABX C18 for both 18f4550 and 18f46k20. Eventually got them to compile and test/debug correctly and run on the PIC. After I choose, "make and program device" It works but I can no longer run debug or re-program the chip. Always says the device doesn't match, etc. Here is what the output window says:


Connecting to MPLAB ICD 3... Firmware Suite Version.....01.28.07 Firmware type..............PIC18F

Target detected Device ID Revision = 7

The following memory area(s) will be programmed: program memory: start address = 0x0, end address = 0x1ff configuration memory

Programming... program memory Address: c Expected Value: 6a Received Value: 36 Failed to program device


Any ideas?

Thanks

\$\endgroup\$
  • \$\begingroup\$ Without looking at your specific PIC: You may have code protection set. You may have selected a clock type that the programmer does not support. These problems are usually recoverable by following a suitable path. The device should be able to be erased with code protection set. Worst case if it is not seeing your programmer clock or crystal you may have to uses ICSP with the PIC in a breadboard and supply a clock source or crystal or resonator or RC network or whatever that allows the PIC to run so it can listen to the programmer well enough to find its way home. \$\endgroup\$ – Russell McMahon Oct 24 '12 at 6:24
  • \$\begingroup\$ So there's some protection bits in the PIC and if you accidentally set them you can't just program. But if you have the ICD3, you should be able to do a "full erase" or something to that effect (it's been a while since I looked in MPLAB) which will clear everything, including the protection bits. Try that, then reprogram. \$\endgroup\$ – Kit Scuzz Oct 24 '12 at 7:13
3
\$\begingroup\$

The PIC may have been told to 'raise its shields' or may have been programmed to not respond to the programmer clock or oscillator control network. These problems are usually recoverable by following a suitable path. A circuit diagram of your target application may be useful.

Without looking at your specific PIC:

You may have code protection set.
The device should be able to be erased with code protection set.

You may have selected a clock type that the programmer does not support.
Worst case if it is not seeing your programmer clock or crystal you may have to uses ICSP with the PIC in a breadboard and supply a clock source or crystal or resonator or RC network or whatever that allows the PIC to run so it can listen to the programmer well enough to find its way home.

There is a small chance that it has been damaged in the process and is irrecoverable. Be sure to use adequate anti-static precautions and correct operating voltages, insert and remove with power off, ensure that no signal levels exceed absolute maximum values.

\$\endgroup\$
  • \$\begingroup\$ protection bits are all turned off. for some reason, when I take it out of the circuit and rebuild on breadboard, using ICSP/ICD3 and a few attempts, it would respond normally. Not sure what all that was about. Thanks for the tips. \$\endgroup\$ – Mark Oct 24 '12 at 7:17
  • \$\begingroup\$ @Mark - Breadboard obviously addressed the clock issues correctly as it ran for you. This MAY have allowed you to move it "back into the fold" where the programmer clock was again legal. What clock did you set in the target mode? What clock is used in the programmer. I have not programmed a PIC "for some while" but I found that when "playing" it was useful to initially use an internal clock mode when available so that the processor always has a legal clock source. \$\endgroup\$ – Russell McMahon Oct 24 '12 at 9:33
  • \$\begingroup\$ I'm using internal clock @ default 1MHz. \$\endgroup\$ – Mark Oct 24 '12 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.