Hi Tony,
Each location or adress in the EEPROM is a byte, a byte is 8 bits. If you do
WRITE 0, 15 you will write the
value 15 to adress 0 of the EEPROM. If you read the value back into a variable the variable will contain the
value 15, if you decide to "print" the value in binary you'll get
00001111, if you decide to print it in hex you'll get
E - it's all the same just different ways for us humans to express it.
If I understand your example with the numbers 11 and 2 correct you want 11 to be stored in the high nibble and 2 in the low nibble, resulting in the full byte containing 10110010, if we express that number in decimal form it's 178. One way to go from your two numbers into a single byte could be:
Code:
FullByte = Number_1 * 16 + Number_2
See, 11*16+2=178.
(Multiplying by 16 can be replaced with four left-shifts so
FullByte = (Number_1 << 4) + Number_2 which is kind of what Dave is doing.)
To get the value back into your two discrete variables you can do something like
Code:
Number_1 = FullByte >> 4 ' This will take the FullByte and shift it four steps to the left, the low nibble will be "pushed" out
Number_2 = FullByte & %00001111 ' This will mask the high nibble.
/Henrik.
Bookmarks