CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Operating time counters question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Zer0flag
Guest







Operating time counters question
PostPosted: Thu Jan 17, 2008 2:53 pm     Reply with quote

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 Smile
Thank you in advance!

Best regards,
Zer0flag
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group