Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

EEPROM problem

Status
Not open for further replies.

jhanus

New Member
Hello,

How to set all (PIC) EEPROM registers during programing to zero, or some other value in asm.
 
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?

thx
 
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.
 
Many programming software has the option to allow user to edit or fill up the EEPROM buffer before downloading to the PIC.

See the image for an example.
 

Attachments

  • FillBuf.gif
    FillBuf.gif
    12.1 KB · Views: 198
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.

Mike.
 
Thank you!, I don't know how to explain the feeling, when you always can rely on someone, in this case electro-tech-online community.

Thanks again!
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top