Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////Setup PWM/////////////
- PR2 = 99; //Set the PWM period by writing to the PR2 register. [PWM Period = [(PR2) + 1] * 4 * TOSC *(TMR2 Prescale Value)]
- CCPR1L = 0; //Set the PWM duty cycle by writing to the CCPR1L register and CCP1CON<5:4> bits.
- TRISC2 = 0 ;//Make the CCP1 pin an output by clearing the TRISC<2> bit.
- T2CON=0x00; //Set the TMR2 prescale value and enable Timer2 by writing to T2CON.[00 = Prescaler is 1].
- CCP1CON = 0b00001100; //Configure the CCP1 module for PWM operation.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement