RPI4 PWM can't be used with Windows11
See original GitHub issueDescribe the bug When I execute the Sample code, I get an error message like the following.
Unhandled exception. System.ArgumentException: No PWM device exists for PWM chip at index 0. (Parameter ‘chip’) at System.Device.Pwm.Channels.Windows10PwmChannel…ctor(Int32 chip, Int32 channel, Int32 frequency, Double dutyCycle) at System.Device.Pwm.PwmChannel.CreateWindows10PwmChannel(Int32 chip, Int32 channel, Int32 frequency, Double dutyCyclePercentage) at System.Device.Pwm.PwmChannel.Create(Int32 chip, Int32 channel, Int32 frequency, Double dutyCyclePercentage) at GPIOTry.Program.Main(String[] args) in D:\Chester\Project\RPI4\Windows\GPIOTry\GPIOTry\Program.cs:line 16
I changed the boot/config.txt according to “https://github.com/dotnet/iot/blob/main/Documentation/raspi-pwm.md”, But the same problem still occurs.
// put sample code here
using System;
using System.Device.Gpio;
using System.Device.I2c;
using System.Device.Spi;
using System.Device.Pwm;
using System.Threading;
namespace GPIOTry
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var gpiocontroller = new GpioController();
PwmChannel pwmcontroller = PwmChannel.Create(0,0,400,0);
pwmcontroller.Start();
gpiocontroller.OpenPin(2, PinMode.Output);
byte bringth = 0;
try
{
while (true)
{
bringth++;
if (bringth == 11)
bringth = 0;
pwmcontroller.DutyCycle=bringth*0.1;
gpiocontroller.Write(2, PinValue.High);
Console.WriteLine("Duty is " + bringth.ToString());
Console.WriteLine("Set GPIO2 High");
Thread.Sleep(1000);
gpiocontroller.Write(2, PinValue.Low);
Console.WriteLine("Set GPIO2 Low");
Thread.Sleep(1000);
}
}
finally
{
pwmcontroller.Stop();
gpiocontroller.ClosePin(2);
}
}
}
}
Platform: RPI4B
OS: Windows11
System.Device.Gpio: 1.5.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (10 by maintainers)
Top GitHub Comments
I think there’s nothing we can do here, until the low-level drivers are in place.
@raffaeler Pretty complex task to get that installed, but since Windows 11 will (very likely) be officially available for ARM64 (see here: https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewARM64) we should start investigating this setup. Not sure if I find time to do this, but it does sound interesting.