Hi,
Stop thinking of it as individual bits. You have a 16-bit variable (a WORD, 2 bytes) that you've called Adc - in that variable 16 bit variable you have your 10 individual "bits". To save your two bytes to the EEPROM:
Code:
WRITE 0, Adc.HighByte ' Store the high byte of the WORD variable at adress 0 in EEPROM
WRITE 1, Adc.LowByte ' Store the low byte of the WORD variable at adress 1 in EEPROM
Then to read it out and put it back in the variable called Adc:
Code:
READ 0, Adc.HighByte
READ 1, Adc.LowByte
And again, there's really no need to write each indivudal bit to the port like your doing (perhaps there's another reason not shown?), simply do
Code:
PortD = Adc.LowByte
PortB.0 = Adc.8
PortB.1 = Adc.9
Or, if you aren't using the top 6 bits of PortB for anything, simply:
Code:
PortD = Adc.LowByte
PortB = Adc.HighByte
/Henrik.
Bookmarks