Create digital outputs pwm

The DAQ features 8 PWM-capable digital outputs which can be controlled as a group or individually. To work with a PWM digital output, it needs to be allocated with the Add() function: var d0 = (GpioOutputPwm)daq.Add(new GpioOutputPwm(GpioId.D0)); If a PWM digital output is no longer needed, it must be freed with a call to the Remove() function: daq.Remove(d0); The following sample can be tested by connecting an LED and a resistor to each PWM digital output (D0-D7) of the DAQ.

Advanced configuration

PWM digital outputs are controlled by hardware timers on the DAQ. The default frequency of the timers is set to 1kHz to make it easy to compute pulse duration (a.k.a Pulse Width). If needed, the frequency of the timers (a.k.a Time Base) can be changed with a call to SetGpioPwmTimeBase(); In addition, the following PWM digital output groups share the same time base (see GpioTimerId in GpioAttributes.cs for details):

D2, D3, D5 share the same time base
D6, D7 also share the same time base
Finally, the time base can be further controlled through a time base prescaler value between 1 and 65535. This is an advanced time base configuration setting and its usage is documented in the STM32F051 Reference Manual, in section 4.12 Timers and watchdogs.