Joe, I just sent a reply to James with most of the code including the=20 ISR and handler. I believe that this will work but I am still just=20 confused enough that I am not sure. I turn the timer off. I disable=20 interrupts. I reset the timer values to the their original values. I=20 re-enable the interrupts and then I turn the timer back on. Is this the=20 way to do it? Yes, the timer is set up for a 1:8 prescaler. I play will=20 with the other values after I get this basic part working. I like to get=20 a basic program going and then modify only one part at a time. I find=20 that to be easier for me. Thanks, rich! On 7/21/2014 11:59 PM, IVP wrote: >> TMR1H =3D 0x0B; >> TMR1L =3D 0xDC; >> } >> Doesn't that set the timer registers back to 0 and as soon as I >> turn the timer back on it will count to the proper value for 100mS? > The timer counts up from 0000 to FFFF and then wraps around to > 0000. The instruction which sends it over FFFF to 0000 also sets > the interrupt flag, TMR1IF. > > Only TMR2, the PWM timer, can be thought of as "counting to" a > particular value, in that case a hardware match. Otherwise, all the > timers count up to and through FFFF (or FF for 8-bit timers) > > 0x0BDC =3D 3036 decimal. > 0x0000 is not only 0, but also 0xFFFF + 1, or 65536 decimal > > So, in the context of count-up-to-0000, 3036 represents 65536- > 3036, or -62500. > > That is, 62,500 cycles are required to get the timer from 0x0BDC > up to 0000, passing through FFFF > > At 5,000,000 Hz (20MGz crystal) instruction frequency, 100ms is > 500,000 cycles, whch is too big to hold in the 16-bit counter of > TMR1H : L. A count of 62,500 cycles without a pre-scaler is only > 12.500ms > > There are two options - > > (1) Use a pre-scaler. This will allow a higher count but resolution is > coarser. A pre-scaler of 1:8 will give you a count value of 500,000/ > 8 =3D 62,500. Which you have. Apologies if I missed you setting the > pre-scaler in any of the code you posted. > > (2) Change 0x0BDC to 0x3CB0 (-50,000 decimal) and generate an > interrupt every 10ms, without using the pre-scaler > > Joe --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .