Sounds simple, but hard to do:
24.3.2 SETUP FOR PWM OPERATION
The following steps should be taken when configuring
the CCP1 module for standard PWM operation:
1. Disable the CCP1 pin output driver by setting
the associated TRIS bit.
2. Load the PR2 register with the PWM period
value.
3. Configure the CCP1 module for the PWM mode
by loading the CCP1CON register with the
appropriate values.
4. Load the CCPR1L register and the DC1B1 bits
of the CCP1CON register, with the PWM duty
cycle value.
5. Configure and start Timer2:
• Clear the TMR2IF interrupt flag bit of the
PIR1 register. See Note below.
• Configure the T2CKPS bits of the T2CON
register with the Timer prescale value.
• Enable the Timer by setting the TMR2ON
bit of the T2CON register.
6. Enable PWM output pin:
• Wait until the Timer overflows and the
TMR2IF bit of the PIR1 register is set. See
Note below.
• Enable the CCP1 pin output driver by clearing the associated TRIS bit.
I guess, I need to alter step #4 each time, but how to do that in PBP is beyond my understanding...
Bookmarks