I know there are many questions about using pwm pins in RPi, but nothing helpfull for me. Here is my code with described error:

#include "pch.h"
#include "MainPage.xaml.h"
using namespace l298n_z_pwm;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::Devices::Gpio;
using namespace Windows::Devices::Pwm;
using namespace Windows::Devices::Enumeration;

Windows::Devices::Gpio::GpioPin ^pin_in_1;
Windows::Devices::Gpio::GpioPin ^pin_in_2;
Windows::Devices::Pwm::PwmPin ^pin_pwm;//it's ok


auto gpio = GpioController::GetDefault();
auto pwmc = PwmController::GetDefaultAsync();//it's ok too
int i_pin_in_1 = 26;
int i_pin_in_2 = 19;
int i_pin_pwm = 4;
**pin_pwm = pwmc->OpenPin(i_pin_pwm);//Here i got error: Error (active)     class "Windows::Foundation::IAsyncOperation<Windows::Devices::Pwm::PwmController ^>" has no member "OpenPin"**
pin_in_1 = gpio->OpenPin(i_pin_in_1);
pin_in_2 = gpio->OpenPin(i_pin_in_2);

On msdn I found :https://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.pwm.aspx , as we can read there is OpenPin method. Does anyone know how to fix it or make working 5V PWM pins on RPi2 B working on Windows IOT? ohh.. forget to say, I use C++.

  • could it be that pi 4 is not a pwm pin? :) which pi do you use? pi2? take a look a this picture, maybe it could help even if this is pi4j (java) pi4j.com/pins/model-2b-rev1.html Jan 10, 2016 at 12:13
  • I use pi2, i think it's pin 4(I mean phisical pin, no gpio pin)
    – 3Qax
    Jan 10, 2016 at 22:15

1 Answer 1


You probably by now would have found answer. In case you are still looking for this, here is my answer: I have used PWM mode in Raspberry pi without any problem. The only thing that is probably not documented properly is in order to use PWM namespace, you must enable DMA mode in pi. This is how it is done: In your default AppManager screen (Windows Devices Web Portal) select Devices and under Default Controller Driver, select Direct Memory Mapped Driver. Restart your pi. This will work without any issues

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.