NU32v2: Output Compare, PWM, and Analog Output
From Mech
Jump to navigationJump to searchCode for PWM:
OpenTimer2(T2_ON | T2_PS_1_4, 1000); // for 20kHz PWM: 80000000Hz / 4ps / 20000Hz = 1000 OpenOC1(OC_ON | OC_TIMER2_SRC | OC_PWM_FAULT_PIN_DISABLE, 0, 0); // PWM output on Pin D1 SetDCOC1PWM(duty); // unsigned int duty from 0-1000