PDA

View Full Version : Using on-chip EEPROM (DATA) memory like serial memory - possible?



flotulopex
- 1st March 2007, 07:34
Hello,

I'm trying to find out how tu use the on-chip EEPROM (DATA) memory like a serial memory.

It is not about reading one byte after another byte; this is obvious.

No, actually, if I encode data in 5 bits and don't want to lose the 3 bits left, it will be tiresome to retrieve the data if I have to manipulate this byte by byte.

In my case, I have a 16F88 where the data memory adresses are from $00 to $0FF (256 bytes) and I would like to read the first bit from the MSB in the first memory location to the last bit from the LSB in the last memory location; bitwise.

Having a look at Melanie's thread about referencing (in the FAQ), I was imaginating some trick to realize this (creating a memory array or whatever).

The datasheet sais "The EEPROM data memory allows single byte read and write".

I've learned up to now that datasheet say what you can do but not always what you cannot do.

So, is it or is it not possible?

Darrel Taylor
- 1st March 2007, 12:15
Hmmm, bitwise EEPROM,

How bout ...
EEPROM 0,[0,1,2,3,4,5,6,7,8,9,0] ; Just some data to work with

TheBit VAR WORD ; (256*8 = 2047 max)

TheByte VAR BYTE
BitMask VAR BYTE
Result VAR BYTE

TheBit = 42
GOSUB GetEEbit
; Result = 1 (bit 2 of byte 5)
STOP

GetEEbit:
TheByte = TheBit / 8
BitMask = DCD (TheBit // 8)
READ TheByte, Result
Result = Result & BitMask
if Result then Result = 1
RETURN

flotulopex
- 1st March 2007, 14:45
Hello Darrel,

Thanks a lot. It works absolutely perfect and it is just "upseting" me since this solution seems now so obvious; I have almost shame I have asked...

Again (for me), it is a math problem; nothing to do with possible or not.

Time to go back to my PC & breadboard and finish this project...

Thank you very much.

skimask
- 2nd March 2007, 05:12
Hello Darrel,

Thanks a lot. It works absolutely perfect and it is just "upseting" me since this solution seems now so obvious; I have almost shame I have asked...

Again (for me), it is a math problem; nothing to do with possible or not.

Time to go back to my PC & breadboard and finish this project...

Thank you very much.

What about that post from Melanie awhile back about accessing variable arrays by the bits...

http://www.picbasic.co.uk/forum/showthread.php?t=544

It just might be even easier for you to use one of these methods

EDIT TO THE EDIT-ee (which is me) --> WHOOPS! I just saw that you've already seen that one! My bad...

Darrel Taylor
- 2nd March 2007, 06:12
Thanks a lot. It works absolutely perfect ...

Excellent!


... since this solution seems now so obvious

It's always easy when the answers right in front of you.
It's before then, that's the problem. :)

No sweat.
<br>