Author Topic: Erasing a PIC  (Read 2552 times)

0 Members and 1 Guest are viewing this topic.

Offline AtomAmp

  • Contributor
  • Posts: 8
Erasing a PIC
« on: December 05, 2013, 05:23:45 pm »
If you place a brand new PIC in a programmer and click on, "Erase" will it lose it's initial program?
 

Offline Mr Smiley

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: gb
Re: Erasing a PIC
« Reply #1 on: December 05, 2013, 05:36:47 pm »
Depends

Firstly are you talking about a pic with a bootloader, i can't answer that cos I’ve never played with bootloaders on pic's ( yet )

If it doesn't come with a bootloader then there is no 'program', it's blank.

On some pic's there is a clock calibration value stored at ox3ff ( if i remember correctly ). Some programmers will read this value, erase the chip and then re-write the saved value back, and then again, some won't.

I've always found the pickit2 erases it and doesn't re-write. But pickit2 does have a clock calibration option.

 :)
There is enough on this planet to sustain mans needs. There will never be enough on this planet to sustain mans greed.
 

Offline macboy

  • Super Contributor
  • ***
  • Posts: 2014
  • Country: ca
Re: Erasing a PIC
« Reply #2 on: December 05, 2013, 07:47:30 pm »
PIC chips from factory are shipped blank, except for an oscillator calibration, usually stored in the highest address. There is no "initial program". All locations are usually "all 1's" or "all 0's", either of which execute as a NOP.

If you buy a chip that is pre-programmed with a bootloader, then generally you do not use a programmer (e.g. pickit 3) to re-program this, you use the bootloader. The bootloader is designed to not erase itself.

Pickit 3 allows you to specify a range to be erased and/or programmed (usually pre-defined chunks/blocks). I am not sure if this works with all devices, but I know that some devices allow block erasing rather than whole-chip erasing. One caveat is that you may need to do a whole-chip erase to clear some configuration bits (like code protect). Good old PIC16F877 is a chip that supports 'block' erase and per-block code protection. Many many more support it too.

If you accidentally use a programmer to erase a bootloader from a PIC, you can use the same programmer to program the bootloader back onto the chip. You usually need only the HEX file.
 

Offline AtomAmp

  • Contributor
  • Posts: 8
Re: Erasing a PIC
« Reply #3 on: December 10, 2013, 09:11:42 pm »
Thanks guys...!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf