42 #define PWM_PERIOD 20000 // desired period, in us
44 #define MIN_PW 600 //minimum pulse width, in us
45 #define MAX_PW 2400 //maximum pulse width, in us
47 void configTimer2(
void) {
48 T2CON = T2_OFF | T2_IDLE_CON | T2_GATE_OFF
61 void configOutputCompare1(
void) {
65 CONFIG_RB3_AS_DIG_OUTPUT();
66 #if (defined(__dsPIC33E__) || defined(__PIC24E__))
74 #if (defined(__dsPIC33E__) || defined(__PIC24E__))
76 OC1CON1 = OC_TIMER2_SRC |
80 OC1CON = OC_TIMER2_SRC |
81 OC_PWM_FAULT_PIN_DISABLE;
87 void _ISR _T2Interrupt(
void) {
94 u32_temp = ((u32_temp * (u16_maxPWTicks-u16_minPWTicks))>> 10) + u16_minPWTicks;
103 configOutputCompare1();
104 CONFIG_AN0_AS_ANALOG();
110 printf(
"PWM PW (us): %ld \n",u32_pw);