I am trying to work with PWM but failed to access the onboard led. None of the examples found on the forum will function as expected.
The simple example below crashes on a Netduino1 with the 4.2.01 framework.
[font="'courier new', courier, monospace;"]using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace NetduinoApplication1
{
public class Program
{
public static void Main()
{
PWM pwm = new PWM(PWMChannels.PWM_ONBOARD_LED, 100, 0.5, false);
pwm.Start();
Thread.Sleep(Timeout.Infinite);
}
}
}[/font]
As soon as it hits the pwm initialization, the board freezes. After many variations of this code and too many erase&reboot sessions, I have checked the enumeration of the available PWMChannels.
[font="'courier new', courier, monospace;"] Debug.Print("None: " + PWMChannels.PWM_NONE.ToString());
Debug.Print("LED: " + PWMChannels.PWM_ONBOARD_LED.ToString());
Debug.Print("Pin 3: " + PWMChannels.PWM_PIN_D3.ToString());
Debug.Print("Pin 5: " + PWMChannels.PWM_PIN_D5.ToString());
Debug.Print("Pin 6: " + PWMChannels.PWM_PIN_D6.ToString());
Debug.Print("Pin 9: " + PWMChannels.PWM_PIN_D9.ToString());
Debug.Print("Pin 10: " + PWMChannels.PWM_PIN_D10.ToString());
Debug.Print("Pin 11: " + PWMChannels.PWM_PIN_D11.ToString());[/font]
Rather disturbing debug.print results:
[font="'courier new', courier, monospace;"]None: -1
LED: -1
Pin 3: -1
Pin 5: 0
Pin 6: 1
Pin 9: 2
Pin 10: 3
Pin 11: -1[/font]
Same code for PWM_Pin_D6 works as expected (checked with a logic analyzer).
Is the code freezing due to the missing mappings for these pins? And, can I do something to access the onboard led and the pins 3 and 11?
Regards, Sinan