42 #define PWM_PERIOD 20000 // desired period, in us
45 void configTimer2(
void) {
46 T2CON = T2_OFF | T2_IDLE_CON | T2_GATE_OFF
58 void configOutputCompare1(
void) {
60 #if (defined(__dsPIC33E__) || defined(__PIC24E__))
67 #if (defined(__dsPIC33E__) || defined(__PIC24E__))
69 OC1CON1 = OC_TIMER2_SRC |
74 OC1CON = OC_TIMER2_SRC |
75 OC_PWM_FAULT_PIN_DISABLE;
79 void _ISR _T2Interrupt(
void) {
86 u32_temp = (u32_temp * (PR2))>> 12 ;
99 configOutputCompare1();
100 CONFIG_AN0_AS_ANALOG();
108 printf(
"PWM PW (us): %ld \n", u32_pw);