Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[General] How to erase eeprom data on pic 16F628A

Status
Not open for further replies.

katech

Newbie level 2
Joined
Sep 14, 2016
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
24
Hello , forum members.

I have a pic 16F628A and there´s some data writen in de eeprom with the code below:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
if((mac[0] + mac[1] + mac[2] + mac[3] + mac[4] + mac[5] + mac[6] + mac[7] + mac[8] + mac[9] + mac[10] + mac[11]) == 0)
               {
                  if(DEVICES>0)
                     output_high(PIN_A0);
                  mac[0] = incomming[5];
                  mac[1] = incomming[6];
                  mac[2] = iincomming[8];
                  mac[3] = incomming[9];
                  mac[4] = incomming[11];
                  mac[5] = incomming[12];
                  mac[6] = incomming[14];
                  mac[7] = incomming[15];
                  mac[8] = incomming[17];
                  mac[9] = incomming[18];
                  mac[10] = incomming[20];
                  mac[11] = incomming[21];
                  
                  for(v = 0; v<12; v++)
                  {
                     write_eeprom(v,mac[v]);
                     delay_ms(20);
                  }


As you can see it´s a mac address.
I want to erase this mac address with a command like bbtt or something else.
Is there anyone who knows the way to do this.
I only want to erase the mensioned mac address and not the whole chip program.
Can anyone help me with this.

Thanks in advance.

Greetings
Emil
 
Last edited by a moderator:

Why don't you create your own "bbtt" function ( whatever it means ) just by encapsulating the above routine within it ?
 

Why don't you create your own "bbtt" function ( whatever it means ) just by encapsulating the above routine within it ?


Because this peace is to write , but i do not know houw to erase.
I don´t know the identifier for this pic to erase the stored data in that section.

Thanks for your answere.
Greeting
Emil
 

I only want to erase the mensioned mac address and not the whole chip program
The erasing of determined adreesses of memory is the same as writing "default" values to there.
 

Code:
for(v = 0; v<12; v++)
                  {
                     write_eeprom(v,mac[v]);
                     delay_ms(20);
                  }

change
write_eeprom(v,mac[v]);
to
write_eeprom(v,0xFF);

In other words, just write a fixed value to the EEPROM, I think 0xFF is the default for blank EEPROM but you can use any constant you like.
For faster 'erasing' use the EEPROM interrupt flag to tell you when the write cycle has finished instead of using a fixed delay.

Brian.
 

You don't say which compiler and programmer etc. you are using.
If you are using the XC8 compiler then you can use the __EEPROM_DATA() macro or declare variables as __eeprom with initialiser values and these will be put into the EEPROM when the device is programmed.
If I remember correctly, the default is for the linker to initialise the EEPROM so it is erased when the device is programmed but this can be controlled using the linker scripts (and overridden as mentioned above).
Of course you can adjust the values at runtime and these will be retained when the device is powered down, but this will let you control the EEPROM during the device programming.
Susan
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top