Friday, 6 November 2015

PWM programming of PIC16F877A

#include<pic.h>
void delay(int);
void main()

{
TRISC=0X80;
TMR2ON=1;

CCP1CON=0X0C;
CCP2CON=0X0C;

CCPR1L=0;
CCPR2L=0;
delay(1);

CCPR1L=255;
CCPR1H=0X00;
delay(1);
CCPR1L=200;
CCPR1H=0X00;
delay(1);
CCPR1L=170;
CCPR1H=0X00;
delay(1);
CCPR1L=100;
CCPR1H=0X00;
delay(1);
CCPR1L=0;
CCPR1H=0X00;
while(1);


}
void delay(int a)
{
int i;
for(i=0;i<a*1000;i++);
}

No comments:

Post a Comment