NU32v2: Output Compare, PWM, and Analog Output

From Mech
Revision as of 00:54, 30 January 2011 by Lynch (talk | contribs) (New page: Code for PWM: <pre> 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 out...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Code 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