Whether you wish to refer to a value in its decimal, hexadecimal, or binary format, when storing to the EEPROM, you are simply storing that value. When you READ it back, you may need to format it in its hexadecimal format for sending information serially, or displaying to an LCD. It looks like you are receiving these digits as ASCii, which allows for letters A-F. My approach would be to first convert the ASCii characters into Nibbles, then group them together into Hex. Finally you can store the Value in your EEPROM.
To convert an ASCii character to a Hex nibble, subtract $30 from the numeric value of that nibble. Characters 0 >> 9 will be their 0 >> 9 raw value. Capital letters start at $41. Example, actual ASCii value of $41 = "A". You could use IF New_Data > $39 THEN : GOSUB DecodeLetters, ELSE : GOSUB DecodeNumbers. Using the shift and mask code listed previously, group your high nibble and low nibble together to create a new and complete byte value. Repeat for each 2-character grouping. When READing from the EEPROM, use the HEX modifier to send "Value" serially (ASCii representation). The key is that your ASCii value is $30 + Numbers (0 >> 9) and $37 + Letters (A >> F); conversely, ASCii - $30 = 0 >> 9 value while ASCii - $37 = A >> F values.
Bookmarks