Subversion Repositories Code-Repo

Rev

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

#include "defines.h"
#include "PWM2.h"

void PWM2_Init(void) {
    OC2CON = 0x0000;
    OC2R = 0x0001;     // PWM initial duty cycle
    OC2RS = 0x0001;    // PWM duty cycle
    OC2CON = 0x0006;   // PWM off, 16-bit, timer 2, fault pin disabled

    IFS0CLR = 0x00000100;   // Disable Timer 2 interrupt
    T2CONSET = 0x8000;      // Turn on Timer 2
    PR2 = 0x0003;           // PWM period ~ 16-20Mhz
}

void PWM2_Start(void) {
    OC2CONSET = 0x8000;
}

void PWM2_Stop(void) {
    OC2CONCLR = 0x8000;
}