Okey, I thought I solved this problem, but I did not.
I want to write some predetermined values in EEPROM, for beginning all ZEROs would be great.
I managed to write during programing one value with de directive, and rest I filled out in PK2 software which is not a good solution.
I could write a loop which would fill EEPROM with ZERos, but why doing the same job twice, then again, this loop will have to be connected to some switch, because what is the purpose of EEPROM if it will get cleared every time I power it on.
So to resume: How to set all EEPROM to ZERO during programing?
hi,
You could consider using a EEPROM location as a 'control' flag.
For example. assume that the highest location in the EE contains a 'control' byte. Ranging from 0 thru 255.
You preload this byte location.
During the assembly process the assembler, using conditional assembly [after testing the byte] loads the EE with your the parameters of choice.
When you are ready to program the PIC, load the EE control byte with say 0x00 which tells the program sequence [ when the PIC is powered up] to skip the EE preload code section.
Just include a section ORGed at 0x2100 in your code.
I.E.
Code:
org 2100h
data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
The above will fill the first 128 locations of EEPROM with zero when it is programmed. If your chip has 256 bytes of EEPROM then double the number of data statements.