Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "maindefs.h"
#include "pwm.h"
#include <pwm.h>
void pwm_init() {
// Configure pins RC5 and RC7 as outputs
TRISCbits.TRISC0 = 0;
TRISCbits.TRISC1 = 0;
LATCbits.LATC0 = 0;
LATCbits.LATC1 = 0;
RPOR11 = 14; // Set RP11 to ECCP1 PWM Output Channel A
RPOR12 = 18; // Set RP12 to ECCP2 PWM Output Channel A
}
void pwm_start() {
OpenEPWM1(0xFF, ECCP_1_SEL_TMR12);
SetDCEPWM1(500);
SetOutputEPWM1(SINGLE_OUT, PWM_MODE_1);
OpenEPWM2(0xFF, ECCP_2_SEL_TMR12);
SetDCEPWM2(500);
SetOutputEPWM2(SINGLE_OUT, PWM_MODE_1);
}
void pwm_stop() {
CloseEPWM1();
CloseEPWM2();
}