Nevermind... figured it out. On 7/20/2014 5:09 PM, Neil wrote: > Hmmm... tinkering with PWM (for the first time) on an 18F45K22 and can't > get it to work. I'm using timer-6 on RB3 (CCP2) which is the only > output I'm trying to PWM for now, and for now I'm using fairly random > values for PR6 and CCPR2L. I'm following the PWM setup sequence in > section 14.3.2 of the datasheet (DS41412D). Any clues to what else I am > missing here? > > > #pragma config CCP2MX =3D PORTB3 > > > void init(void) > { > ... > ... > TRISBbits.TRISB3 =3D 1; // RB3/CCP2 =3D Input for no= w. > CCPTMRS0 =3D 0b00010000; // CCP2 uses TMR6 > PR6 =3D 123; > CCP2CON =3D 0b00111100; // ECCP: Single output, PWM > LSB + PxA active-high > CCPR2L =3D 200; // Sets PWM width (together > with CCP2CON<5:4>) > PSTR2CON =3D 0b00000001; // Only enable P2A > PIR5bits.TMR6IF =3D 0; > T6CON =3D 0b00000100; // Timer 6 on, no prescale > TRISBbits.TRISB3 =3D 0; // Enable RB3/CCP2 output > ... > } > > Thanks. > --=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 .