10,20 → 10,22 |
LATCbits.LATC1 = 0; |
|
RPOR11 = 14; // Set RP11 to ECCP1 PWM Output Channel A |
RPOR12 = 18; // Set RP12 to ECCP2 PWM Output Channel A |
RPOR12 = 15; // Set RP12 to ECCP1 PWM Output Channel B |
} |
|
void pwm_start() { |
OpenEPWM1(0xFF, ECCP_1_SEL_TMR12); |
SetDCEPWM1(500); |
OpenEPWM1(0xFF, ECCP_1_SEL_TMR12); // 38kHz Frequency |
SetDCEPWM1(512); // 50% Duty Cycle |
|
// Wait for completion of a full PWM cycle before enabling output mode |
while(!PIR1bits.TMR2IF); |
SetOutputEPWM1(SINGLE_OUT, PWM_MODE_1); |
|
OpenEPWM2(0xFF, ECCP_2_SEL_TMR12); |
SetDCEPWM2(500); |
SetOutputEPWM2(SINGLE_OUT, PWM_MODE_1); |
// Enable ECCP1 output channels A and B |
PSTR1CONbits.STRA = 1; |
PSTR1CONbits.STRB = 1; |
} |
|
void pwm_stop() { |
CloseEPWM1(); |
CloseEPWM2(); |
} |