The PWMPortFS class controls one of the two PWM bus On Chip Peripheral (OCP) devices integrated into the Raspberry Pi 2 CPU via the PWM file system access method.
Note that the device tree overlays that ship with the default Raspian operating system (at the time of writing this documentation) do not work properly. You will need to download a version of the device tree overlays that enables an internal hardware clock. See the notes on the PWM Port Example page for more information.
IMPORTANT NOTE: Before creating any RPICSIO Port class you will need to ensure that the RPICSIO Library knows which type of Raspberry Pi you are dealing with. This is done by executing a call (only once is necessary) like the one below somewhere in your code before you create any port.
RPICSIOConfig.Instance.RPIType = RPITypeEnum.RPITYPE_RPI2;
public class PWMPortFS : PortFS
public PWMPortFS(PWMPortEnum pwmPortIn) : base(GpioEnum.GPIO_NONE)
public override void ClosePort()
public void Dispose()
public override PortDirectionEnum PortDirection()
public uint DutyNS { get; set; }
The duty cycle is the part of the wave form devoted to a high state.
public double DutyPercent { get; set; }
public uint FrequencyHz { get; set;}
public uint PeriodNS { get; set;}
public PWMPortEnum PWMPort { get; }
public bool RunState { get; set;}