Subversion Repositories Code-Repo

Rev

Rev 231 | Details | Compare with Previous | Last modification | View Log | RSS feed

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