PWM algo

Status
Not open for further replies.

fusian

New Member
1. configure CCP1 pin output

2. set PWM period(PR2 + T2CON)

3. set initial PWM duty cycle by writing to CCPR1L:CCP1CON<5:4>

4. enable timer2 int (TMR2IF=0,TMR2IE=1)

5. change PWM duty cycle as you like by writing to CCPR1L:CCP1CON<5:4> during TIM2 ISR. Goto 4.

conceptually, are the above algo correct? my application is to generate different duty cycle of PWM by user request. so can i do it following the algo above by changing the duty cycle during ISR?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…