Using eeprom for the first time- Help please

1. ## Using eeprom for the first time- Help please

Hi
I am using PIC 16F690 and here is a fraction of my code. I have written this code so it stores my phone number and only enters once under this label "first:". Code does not seem to enter this label to being with - Is there somthing wrong with my code?
first:
if a<>"6" and b<>"8" and c<>"4"then
for c=0 to 255
write c,0
next c
write 230,"6"
write 231,"8"
write 232,"4"
pause 5000
for c=0 to 12
next c

write 200,"+" : write 201,"4" : write 202,"4" : write 203,"7" : write 204,"8" : write 205,"3" : write 206,"2" : write 207,"2" : write 208,"2" : write 209,"5" : write 210,"1" : write 211,"7" : write 212,"4" ' this is all in one line
for c=200 to 212
next c
endif

2. Did you find this post helpful? |
Hi financecatalyst,
Wow, that's one heck of an If/Then loop, I never had any success trying to cram that much into one. If it were me I would build a subroutine for all that stuff and return after. Not really experienced with Write too much and of course I am not at my bench to try it out, but might add a short pause, say 10 or 15 ms after each write.
Code:
So you have a 255 byte array ?
Not sure I understand this otherwise . . .
and it works with c-200 ?

3. Did you find this post helpful? |

Code:
write 200,"+" : write 201,"4" : write 202,"4" : write 203,"7" : write 204,"8" : write 205,"3" : write 206,"2" : write 207,"2" : write 208,"2" : write 209,"5" : write 210,"1" : write 211,"7" : write 212,"4" ' this is all in one line
for c=200 to 212
next c
You can write eeprom only once when you program your pic with this instruction at the begining of your program:

Code:
EEPROM 200,[43,52,52,55,56,51,50,50,50,53,49,55,52]

for c=200 to 212
next c

But you should avoid to use this peace of code (In red) otherwise you will erase your phone #

Code:
if a<>"6" and b<>"8" and c<>"4"then
for c=0 to 255
write c,0
next c
...........
...........

Code:
if a<>"6" and b<>"8" and c<>"4"then
for c=0 to 199
write c,0
next c
..........
..........

In order to avoid holes in the eeprom you can change location to your phone # like this:

Code:
EEPROM 243,[43,52,52,55,56,51,50,50,50,53,49,55,52]

for c=243 to 255
next c

In this case you could erase up to location 242 and still save you phone #.

Code:
if a<>"6" and b<>"8" and c<>"4"then
for c=0 to 242
write c,0
next c
..........
..........
Al.
Last edited by aratti; - 11th October 2009 at 11:54.

4. Did you find this post helpful? |
Hi
Thanks for the input.
I wanted to fill the whole eeprom with "0" for the first time before loading any numbers to it, and choose 3 locations which are away from phone arrays and can mark if the code should enter there (first time) or not (anytime after the first time).

I have managed to make it work. I am having problem with receiving string for my sms controller for which I have started another thread. Your input there will be appreciated.
Thanks Again

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts