PWM with ChipworkX

Hello there,

I’m trying to make a simple buzzer to make sound with a chipworkx development environment.

I’m using the following code:

 public static void Main()
        {
            PWM pwm = new PWM((PWM.Pin)ChipworkX.Pin.PB4);
            pwm.Set(10000, 50);
        }

The design time compiler does not report any errors. Also building is completed without errors. However when I deploy the code and run it an error message pops up with the following error:

[quote]An unhandled exception of type ‘System.ArgumentException’ occurred in GHIElectronics.NETMF.Hardware.dll
[/quote]

I’m using version 4.02 from the GHI SDK. Could someone please tell me what I’m doing wrong?

Many thanks in advance,

Kind regards,

Nick

Try putting a Thread.Sleep(Timeout.Infinite) after setting the PWM.

I assume the firmware on the Chipx matches the ghi and ms sdks you are using.

Please see library documentation.

It says

[quote]ChipworkX
Only one channel is available (0) with four frequencies: 391 KHz, 195 KHz, 98 KHz and 49 KHz.[/quote]

PWM on ChipworkX is meant to be used for backlight control and nothing more fancy.

You can generate tones on any IO using OutputComare microframeworkprojects.com