Hex minus Dec Problem
Sutton Murray
Posts: 88
Greetings
I am battling with minimizing two varibles from each other.
The first varible is loaded with a byte from the DS1302(hours) and the second varible byte·is loaded from the stamps EEProm.
When the two is minimized from each other the sum value is incorrect. ( IHours = Hours - IHours)
My thoughts are that·this is as a result that the information retrieved from the EEProm is·in Hex, where that from the DS1302 is in·Dec. Is my thinking·correct in this area?
How will one convert one to a other to do the sum calculation?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For in much wisdom is much grief, and he who increases knowledge increases sorrow." ~Ecclesiastes 1:18
I am battling with minimizing two varibles from each other.
The first varible is loaded with a byte from the DS1302(hours) and the second varible byte·is loaded from the stamps EEProm.
When the two is minimized from each other the sum value is incorrect. ( IHours = Hours - IHours)
My thoughts are that·this is as a result that the information retrieved from the EEProm is·in Hex, where that from the DS1302 is in·Dec. Is my thinking·correct in this area?
How will one convert one to a other to do the sum calculation?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For in much wisdom is much grief, and he who increases knowledge increases sorrow." ~Ecclesiastes 1:18
Comments
The ".nib0"/".nib1" notation is described in the Stamp Manual and it allows you to access the most significant 4 bits and the least significant 4 bits of a byte.
To go back, do: bcdbyte = (binary DIG 1) << 4 + (binary DIG 0)
Look in the Manual for the descriptions of the DIG and << operators.
Battle to understand your script at first, but am making it up. I am now buzy going through Jon Williams "It's time to get real with the dallas 1302". Your line is more advanced(understand how this works), but i will get their.
Thanks for putting me on the right track.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For in much wisdom is much grief, and he who increases knowledge increases sorrow." ~Ecclesiastes 1:18