Sie sind auf Seite 1von 1

void InitMain() { ANSEL = 0; ANSELH = 0; C1ON_bit = 0; C2ON_bit = 0; PORTA = 0; TRISA = 0; PORTB = 0; TRISB = 0; PORTC = 0; TRISC = 0; PORTD = 0; TRISD = 0; PWM1_Init(10000);

CCP1CON.b7 = 1; CCP1CON.b6 = 0; CCP1CON.b3 = 1; CCP1CON.b2 = 1; CCP1CON.b1 = 0; CCP1CON.b0 = 0; PWM1CON = 50; } void main() { InitMain(); PWM1_Start();

// Configure AN pins as digital // Disable comparators

// set PORTC to 0 // designate PORTC pins as output // set PORTD to 0 // designate PORTD pins as output // set PORTC to 0 // designate PORTC pins as output // set PORTD to 0 // designate PORTD pins as output // Initialize PWM1 module at 10KHz // Half bridge mode with dead time // Outputs RC2 and RD5 // P1A and P1B are active high

// 10us dead time

while(1) { Delay_1sec(); PWM1_Set_Duty((25 *255)/100); Delay_1sec(); PWM1_Set_Duty((50 *255)/100); Delay_1sec(); PWM1_Set_Duty((75 *255)/100); Delay_1sec(); PWM1_Set_Duty((50 *255)/100); } }

Das könnte Ihnen auch gefallen