Well, then it will make it simpler to use low frequency OSC, such as standard 32768HZ, using timer0 will give you a tick every 32ms. This is a 32 bit variable in a year, directly supported by many C compilers. Either way, incrementing a variable on every interrupt call with the max timer setting you can afford, will require to handle a multi-byte variable in RAM that is not difficult to maintain even in ASM. Using the carry bit you can handle extremely large multi-byte variables with easy. 2008/4/14, Dave Roseman : > This is a long term timing application, the resolution is 60 minutes, and > would expect it to be in service for years, possibly having a count every > 200us might lead to a too large number.. > > --dave > > -----Original Message----- > From: Ariel Rocholl [mailto:foros@arocholl.com] > Sent: 11 April 2008 16:03 > To: Microcontroller discussion list - Public. > Subject: Re: [PIC] Measuring time a DC signal is on > > Depending on how long that measure can be (seconds? days? years?), you > will need: > > * A timer (better 16bit one than 8bit one, you can choose depending on > it not being already allocated for a peripheral). Take a look on the > datasheet, it is straightforward to enable a timer. > * A timer interrupt, to increment a global variable that will count > how many times the timer carried over. > * A global variable. Let's say that depending on your timer, OSC > frequency and pre/postcaler, you have an interrupt every 200uS. The > variable will increment once every 200uS so depending on how many of > these ticks you need to count, this may go to a 32bits or even 64bits > variable. > > 2008/4/11, Dave Roseman : > > Hi, > > > > > > > > I am using a PIC16F690 to monitor how long a power supply is active for, > but > > I have no idea how to use the timer in the micro to monitor this signal. > It > > does go high when the power is on, but how to get this info to the micro, > I > > don't know. > > > > > > > > Also, this reading is required to be cumulative, so has to remember the > > previous on time and append to it. > > > > > > > > I'm just starting PIC programming, so please forgive me if this is too > > simple or obvious a question. > > > > > > > > Regards > > > > Dave Roseman > > > > -- > > http://www.piclist.com PIC/SX FAQ & list archive > > View/change your membership options at > > http://mailman.mit.edu/mailman/listinfo/piclist > > > > > -- > Ariel Rocholl > Madrid, Spain > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- Ariel Rocholl Madrid, Spain -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist