Zer0flag Guest
|
Operating time counters question |
Posted: Thu Jan 17, 2008 2:53 pm |
|
|
Hi all!
I have implemented an operating time counter for my device. It is a 32 bit (!) counter variable that is incremented by the 16 bit Timer 3 interrupt. This counter variable is saved to eeprom on power off and loaded on power on. The counter increments every 1.6 us and overflows every 2^16*1.6 us. This makes the counter set-and-forget and gives me a very long possible operating time of many years. If I know the value of the counter and use a normal calculator I can recalculate the time in hours. I would first calculate:
(32bit_counter * 2^16 * 1.6 us) and then recalculate the value from us in hours.
My question is if I can do the same recalculation in hours using my PIC18. The problem here is that the numbers become extremely big (counter is already 32 bit) and if I divide too early the result becomes extremely inaccurate.
Maybe there is another way to do it so I will be very happy for any hints
Thank you in advance!
Best regards,
Zer0flag |
|