Author Topic: Edit interal EEPROM values of 16F876 PIC with CODE PROTECT  (Read 1582 times)

0 Members and 1 Guest are viewing this topic.

Offline AxxelTopic starter

  • Contributor
  • Posts: 37
  • Country: es
Edit interal EEPROM values of 16F876 PIC with CODE PROTECT
« on: August 15, 2018, 03:50:48 am »
Hi freinds!

Is there any way to edit or reprogram ONLY the internal EEPROM content of a PIC in CODE-PROTECT mode without damaging the existent program? Or replace the content of the EEPROM values to FF FF FF FF content? Keeping the loaded program?

Regards  8)
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2523
  • Country: us
Re: Edit interal EEPROM values of 16F876 PIC with CODE PROTECT
« Reply #1 on: August 15, 2018, 05:07:17 am »
Here's some code I have for a pic16f877a to read/write a byte.  Never had a reason to use it, so I don't know if it works.

Code: [Select]
            // EEPROM Read token...
            //    buffer[2] == address
            //    buffer[3] == data
            case FT_EEPROM_READ:
               EEADR=buffer[2];        // EEPROM address
               EECON1bits.EEPGD=0;     // EEPROM data memory
               EECON1bits.RD=1;        // Initiate read
               buffer[3]=EEDATA;       // EEPROM data
               SendPacket(3);
               break;

            // EEPROM Write token...
            //    buffer[2] == address
            //    buffer[3] == data
            case FT_EEPROM_WRITE:
               EEADR=buffer[2];        // EEPROM address
               EEDATA=buffer[3];       // EEPROM data
               EECON1bits.EEPGD=0;     // EEPROM data memory
               EECON1bits.WREN=1;      // EEPROM write enable
               intrbyte=INTCON;
               INTCON=0;               // Disable interrupts
               EECON2=0x55;
               EECON2=0xAA;
               EECON1bits.WR=1;        // Initiate write
               INTCON=intrbyte;        // Restore interrupt state
               while (EECON1bits.WR);  // Wait for write to complete
               EECON1bits.WREN=0;      // EEPROM write inhibit
               break;
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12807
Re: Edit interal EEPROM values of 16F876 PIC with CODE PROTECT
« Reply #2 on: August 15, 2018, 06:08:53 am »
If the CPD bit in the CONFIG word is zero, then the EEPROM is protected and you are S.O.L.

If its set (its default state after chip erase), the EEPROM can be both read and written by any programmer + programming utility that can be configured to not do a chip erase, and only write the EEPROM memory range.  Setting this up depends on your programmer, and it would be advisable to practice on a new PIC16F876 to confirm you can write to the EEPROM without disturbing the program memory or CONFIG word.

Even if the chip is fully protected, the bits in the CONFIG word can be read back, so you can simply read the chip then examine the CPD bit and the values returned for the EEPROM area to determine if its possible.
 

Offline AxxelTopic starter

  • Contributor
  • Posts: 37
  • Country: es
Re: Edit interal EEPROM values of 16F876 PIC with CODE PROTECT
« Reply #3 on: August 15, 2018, 06:42:56 pm »
Thanks dude for the answer!

the EEPROM can be both read and written by any programmer + programming utility that can be configured to not do a chip erase, and only write the EEPROM memory range.

I have a PicKit2, i've done it!

Just unchek program memory and check EEPROM Data!

As simple as it! Of coure you need having the corrects fuses...

Commercial Photography

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf