Perhaps if you disabled the TMR1 and CCP modules, then reset the timer 1 and CCPR1H:CCPR1L registers, and then reenabled both modules this odd behaviour would disappear. I am guessing that you are getting some kind of transient match condition between the tmr and ccp regs that if triggering CCP1IF. Bob Ammerman RAm Systems > Fwd on behalf of Dan Michaels > > Problem and solution here, DM would appreciate any > insights > > ====================================== > > I'm writing code to use a 16F873 to time 16 R/C servos: > > - 20 mhz xtal > > - using timer0 for epoch timing, 2 "polled" overflows w/prescale=256 > and presetting to 244 gives 2*12.5 msec long epochs [works fine]. > > - using timer 1, in compare mode with CCP1IF interrupts to time the > servo pulses, internal clock, prescale/1, generate s.w. interrupt > on match, CCPR1L = 0Ah. > > - with this setting, CCPR1H:CCPR1L values from 0-20000 give > 0-4000 usec long pulsewidths. > > - I setup for 1st servo pulse, let the interrupt go, and stop timer1. > Then, back in the main programm, clear TMR1H:TMR1L, load > new values into CCPR1H:CCPR1L for the next servo, and re- > start timer1. > > The problem comes in as follows: > > - if I set CCPR1L != 00h with CCPR1H != 00h, everything is ok. > > - but if I set CCPR1L = 00h with CCPR1H != 00h, then the pulse > widths get crazy. > > - eg, CCPR1H:CCPR1L = 1301h --> 973 usec pulse, ok. > CCPR1H:CCPR1L = 1300h --> tiny pulse, few usec. > > I checked the Mchp errata sheets. It seems CCPR1L does > not like a 00h. > > =========================== > B4 I get a chance to fwd this problem to the list, Dan finds - > =========================== > > Solution is: > > - when in compare mode for timer1, with TMR1 off .... > > - if I clear TMR1L and TMR1H registers "before" I set new values into > CCPR1L and CCPR1H, then I get the funny pulsewidth business. > > - but if I clear TMR1x "after" setting new values into CCPR1x, then > everything works fine. Botta bing. > > What gives? > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics