koolguy
Active Member
Hi,
I am want PWM for speed controlling of DC motor for this i am using PIC16F877a...
here is the code written according to the hind in Data shet...
I am want PWM for speed controlling of DC motor for this i am using PIC16F877a...
here is the code written according to the hind in Data shet...
Code:
#include <htc.h>
__CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
#define _XTAL_FREQ 20000000
main(){
TRISC=0x00;// out put for PWM
CCP1CON=0b11111000; //pwm mode
PR2=0xff;//for 19.9khz freq
CCPR1L=0x0f;/duty cycle random
T2CON=0b01100000;//pescallaer to 1:4 don't know why?
CCP1IE=0;//disable interput