• 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.

nonvolatile storage?

Status
Not open for further replies.

evandude

New Member
I need to store something like 20-25 bytes of data with my PIC 16F628, between uses...

what the data consists of is a dozen or so variables that represent different settings, that will be adjusted during use, and having to re-enter the settings every time I power it on is out of the question.

I really don't want to use an external EEPROM, part because it's overkill, and part because I don't think I can afford to waste the code space on the interface, or the physical space on the device.

I've been trying to get the PIC to write data to the Data EEPROM into the unused memory locations, but it doesn't seem to be working (I have it in a loop where it writes to a given location, then reads from that location and compares the value to verify)
I'm assuming thus far that the unimplemented space in the data EEPROM is off limits... is this correct?

and is there any way I can have the program store the values into program memory?

I suppose the alternative is to not power off the PIC ever, rather put it into standby and operate it on a small watch battery for memory backup, or something like that... but I'd really rather not do that either...

thanks in advance for any help you can give me....
 

kinjalgp

Active Member
Whats is the problem with intenal data EEPROM? If its there then you should be able to write into it. I guess the problem lies in your code. May be you require to give some delay after each write command since EEPROMs are slow at writing.
 

evandude

New Member
yeah, I sort of thought of that too.

according to the PIC data sheet, it says that to write, you set the WR bit and the WR bit will be cleared when the write is complete.

after setting the write bit, my program goes into a while loop and waits for the bit to be cleared... and it IS completing the write cycle repeatedly, as it blinks an LED each time the write cycle completes.

I'm doing the writing and reading exactly to the letter, by the book, according to the 16F628 datasheet...

What I'd really like to hear is something from someone who has actually successfully DONE what I'm trying to do, just so I know it's possible. I don't mind screwing with the code and testing repeatedly for several hours, as long as I knew that it was possible in the first place.
 

evandude

New Member
hrm... well in ICProg I always assumed the CPD configuration bit was just part of the code protect thing...

however searching through the PIC datasheet I finally found that the two were separate, that the CPD bit, when SET, would allow writing to the EEPROM data section... although I still think the label given to the checkbox in ICProg was a little ambiguous: "Code Protection Data Enable"...
oh well, live and learn.

I'll have to wait until later to test it...
 

evandude

New Member
hooray!

FINALLY...

setting the CPD bit allows the program to write to data EEPROM. However, on testing, it could not write to eeprom, although I COULD write to data EEPROM from ICProg, and then it would read it correctly...

so I found that the PIC has a sort of "secret handshake", you have to load EECON2 with 55h, then AAh, and then set the WR bit to write. it sounds like the only reason for that is to make sure your program is intentionally writing to EEPROM, instead of by accident... but regardless, after such a big headache, it's working now.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top