Friday, 6 November 2015

MOTOR programming using PWM and USART (PIC16F877A)

#include<pic.h>
void main()
{
char a;
TRISB=0X00;
TRISC=0X80;
TMR2ON=1;
CCP1CON=0X0C;
TXSTA=0X24;
RCSTA=0X90;
SPBRG=0X19;
PORTB=0X03;
while(RCIF==0);
a=RCREG;
RCIF=0;
switch(a)
{
case '1':
{CCPR1L=0;
 break;
}
case '2':
{CCPR1L=50;
 break;
}
case '3':
{CCPR1L=100;
 break;
}
case '4':
{CCPR1L=250;
 break;
}
}
}
)

No comments:

Post a Comment