Advertisement
eng-mg

Setup PWM Module [PIC16F877A]

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