PDA

View Full Version : Write. Read. (How hard can it be?)



Meriachee
- 12th January 2009, 16:51
Hi all,
I'm using a 16f819, which is rumored to have 256 bytes of EEprom. I should be able to define 7 simple byte variables, with 1 or 0, and depending on switch states, write these values to memory so we can remember where we left off the next time we start up.
Using the exact example from the pbp book,
SW1 = 1
led1 = 0
Write 0, SW1
...do something else for a while....
read 0, SW1
if SW1 = 1 then
led1 = 1
endif

Is the issue the address space? Could I use 0 through 6? I don't get what the datasheet is telling me.
Thanks
Gary

rmteo
- 12th January 2009, 18:29
It is no rumour, the PIC16F819 does have 256 bytes of EEPROM. :p
What is the problem that you are having?

Meriachee
- 12th January 2009, 18:35
Sorry, guess I forgot to ask....

The data does not seem to be written, or read (not sure which is failing). If I set the led to blink based on the value of the variable, it does not seem to correspond to the value I am writing.

mackrackit
- 12th January 2009, 19:53
Maybe this will help.
http://www.picbasic.co.uk/forum/showpost.php?p=68757&postcount=15

ErnieM
- 12th January 2009, 21:57
Your programmer may be your friend here. My first choice is a humble PICkit2, which allows EEPROM data to be written and read back out too.

So you can set the initial value, run your program see it that works (to debug reads), then push your buttons and see if the correct value gets there (to debug your writes).