Note that Timer2 is used in conjuction with the CCP modules only for PWM. Triggering a S/W interrupt on match with the value in the CCPRxH & L requires the use of Timer1. (and Timer 3 in the case of the PIC18F). However, you could use the Timer2 interrupt. That is, figure out the prescale and postscale values and a PR2 value that gives roughly 50 ms. For example, if the prescale is 1:256 and PR2 is 195 and the postscale is 1:1, this is 49.92 ms for a 4.0 MHz clock. If you are using a 20 MHz clock, the prescale might be 1:256, PR2 = 244 and the postscale for 1:4. (I am tired and may have made an error here). *********** There is a good deal of confusion caused by the use of the names CCP1 and CCP2 and Timer1 and Timer2 which might falsly lead one to believe that Timer1 is associated with CCP1 and Timer2 with CCP2. This is not true. However, the PR2 register is inherently linked with Timer2. ************** If you subcribe to my C routines distributions, see routine TIMER2_1.C. Hope this helps. Peter H Anderson, http://www/phanderson.com, pha(at)phanderson.com --- cdb wrote: > I am trying to use timer2 on a 16F877 to create an > interrupt roughly > every 50mS. > > To this end I have enabled the software interrupt in > CCP2CON to > software trigger (0x0A), loaded CCPR2L with 'd' 30. > T2CON I have > postscale *16, PIE2 is enabled as is PIE in INTCON > (I'm using TMR1 > elsewhere). > > The value for CCPR2L comes from CLOCK 10MHz /4= > 1/(2.5MHz/256/16/30)=49.15mS > > My problem is that at 51mS the test for CCPI2 in > PIR2 is set - no > problem, however it will not clear until approx 58mS > have passed and > then does not set itself again. > __________________________________________________ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu