Subversion Repositories Code-Repo

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
107 Kevin 1
#include "maindefs.h"
2
#include "pwm.h"
3
#include <pwm.h>
4
 
5
void pwm_init() {
6
    // Configure pins RC5 and RC7 as outputs
7
    TRISCbits.TRISC0 = 0;
8
    TRISCbits.TRISC1 = 0;
9
    LATCbits.LATC0 = 0;
10
    LATCbits.LATC1 = 0;
11
 
12
    RPOR11 = 14;    // Set RP11 to ECCP1 PWM Output Channel A
13
    RPOR12 = 18;    // Set RP12 to ECCP2 PWM Output Channel A
14
}
15
 
16
void pwm_start() {
17
    OpenEPWM1(0xFF, ECCP_1_SEL_TMR12);
18
    SetDCEPWM1(500);
19
    SetOutputEPWM1(SINGLE_OUT, PWM_MODE_1);
20
 
21
    OpenEPWM2(0xFF, ECCP_2_SEL_TMR12);
22
    SetDCEPWM2(500);
23
    SetOutputEPWM2(SINGLE_OUT, PWM_MODE_1);
24
}
25
 
26
void pwm_stop() {
27
    CloseEPWM1();
28
    CloseEPWM2();
29
}