I am using a DS1307 for timekeeping. The device i am constructing is supposed to count the number of hours to a specific date. I have succeded with the communication between the RTC and my PIC16F88.
But i have a problem. The time is stored with HEX representation. The time 13:54 would be 0x13 and 0x54 in the memory of the RTC.
The thing is that i want to figure out the difference in hours. I have two byte variables Hour and xHour. The first is the current hour and xHour is the setup hour to which i am counting down.
BTW i am programming in PicBasic Plus, but i suppose it's just the theory of how to do this that matters.
Example to show my problem:
Hour = 14
xHour = 23
Diff = xHour - Hour
And the result i want is 9. But the result i get is 15 (35 - 20).
I would need to convert the Hour and xHour to decimal representation and then subtract. But how do i do this? Or is there another way of doing this without converting to decimal?
But i have a problem. The time is stored with HEX representation. The time 13:54 would be 0x13 and 0x54 in the memory of the RTC.
The thing is that i want to figure out the difference in hours. I have two byte variables Hour and xHour. The first is the current hour and xHour is the setup hour to which i am counting down.
BTW i am programming in PicBasic Plus, but i suppose it's just the theory of how to do this that matters.
Example to show my problem:
Hour = 14
xHour = 23
Diff = xHour - Hour
And the result i want is 9. But the result i get is 15 (35 - 20).
I would need to convert the Hour and xHour to decimal representation and then subtract. But how do i do this? Or is there another way of doing this without converting to decimal?