Let TIMER1 free run. Read it at the beginning and end of the pulse you are trying to measure. Compute the difference and you are done. Note that you'll get the right answer even if the timer has rolled over during the pulse, as long as it hasn't rolled over more than once. Bob Ammerman RAm Systems ----- Original Message ----- From: "Richards, Justin P" To: Sent: Friday, October 18, 2002 11:40 PM Subject: [PIC]: Timer1 as a software counter 16f628 > Hello, > > Can the Timer1 Module a 16F628 (@4Mhz) be used as a software 16bit counter. > > I have scanned the last 30000 emails and looked at PICLIST.com but all the > discussion seems to be using it driven via hardware. > > I was experimenting with MPLAB and I got TMR1L to rollover to FF when I > decremented TMR1H from FF to 00 but cant repeat the results. I tried all > other combinations but they both appear to behave has 2 separate 8 bit files > when using decf or incf > > I thought perhaps MPLAB does not simulate the TMR1 faithfully. > > What I am trying to do is see how many 26uS units there are in a ext pulse. > Using 8 bits for counter the max pulse width is 6.6mS. 16bit gives 1690mS. > > I got TMR0 to generate 26uS periods but the overheads involved in context > saving and bank switching did leave much time for anything else. It did > work but not enough time to see if an 8bit counter rolled over and then inc > another counter. > > If Timer1 behaved as a 16bit software counter it would save much in > overheads and be a great solution. Anyone used it this way. > > It appears I may need to increase the PIC speed if not. > > Regards > > Justin Richards (T388) > IS&W Meekatharra (Northern Remote) > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads