Subversion Repositories Code-Repo

Rev

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

Rev Author Line No. Line
199 Kevin 1
#include <xc.h>
2
#include <plib.h>
3
#include "defines.h"
4
#include "PWM2.h"
5
 
6
void PWM2_Init(void) {
7
    OC2CON = 0x0000;
8
    OC2R = 0x0001;     // PWM initial duty cycle
9
    OC2RS = 0x0001;    // PWM duty cycle
10
    OC2CON = 0x0006;   // PWM off, 16-bit, timer 2, fault pin disabled
11
 
12
    IFS0CLR = 0x00000100;   // Disable Timer 2 interrupt
13
    T2CONSET = 0x8000;      // Turn on Timer 2
201 Kevin 14
    PR2 = 0x0003;           // PWM period ~ 16-20Mhz
199 Kevin 15
}
16
 
17
void PWM2_Start(void) {
18
    OC2CONSET = 0x8000;
19
}
20
 
21
void PWM2_Stop(void) {
22
    OC2CONCLR = 0x8000;
23
}