Professional Documents
Culture Documents
h>
void main()
{
TRISCbits.TRISC0 = 0 ; // DC Motor IN1
TRISCbits.TRISC6 = 0 ; // DC Motor IN2
TRISCbits.TRISC7 = 0 ; // CCP2 PWM output, DC motor enable
PR2 = 0x4A; //10khz // set PWM period to Maximum value
T2CON = 0x07;
PORTCbits.RC7 = 0;
PORTCbits.RC6 = 1;
while(1)
{
CCP1CON = 0x2C;
CCPR1L = 0x12; //25% Duty Cycle
myMsDelay(1000);
CCP1CON = 0x0C;
CCPR1L = 0x25; //50% Duty Cycle
myMsDelay(1000);
CCP1CON = 0x2C;
CCPR1L = 0x37; //75% Duty Cycle
myMsDelay(1000);
}