There are only 8 PWMChannels (PWMChannel.PWM_0 to PWMChannel.PWM_7) and additionally only four of them work.
If I try to declare a PWM pin like that:
PWM e4 = new PWM((Cpu.PWMChannel) GHI.OSHW.Hardware.FEZCerberus.Pin.PB3 , 10000, 1000, PWM.ScaleFactor.Microseconds, false); // WARNING!!! DON’T DO IT!!!
the cerb40 stops responding when I uploaded the program. Visual Studio and MFDeploy could not see it. I had to reflash it using ST-LINK to restore it in working condition.
Is there a way to use more than 4 PWM pins on 4.2?
it is channel 8, this has nothing to do with the pin number. This is what you need, where 8 is the channel number. This can be any number but NETMF has enums for first 7 only.
The Cerb40 may not have all of the PWM channels exposed on the pins. The Cerb-Family has 16 PWM channels programmed into Micro Framework. Here is a list of Channel to pin on the Cerb-Family:
I run the following code for testing, then I searched all the pins, pin by pin, using a logic analyzer.
Finally, I found 6 PWM pins. There should be at least two more.
I used different dutyCycle to determine which PWMChannel is assigned to each pin. It is easier than reading the board diagram and the cerb40 specs.
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using System.Threading;
namespace MFConsoleApplication3
{
public class Program
{
public static void Main()
{
PWM p0 = new PWM(Cpu.PWMChannel.PWM_0, 500, 0.2, false);
p0.Start();
PWM p1 = new PWM(Cpu.PWMChannel.PWM_1, 500, 0.3, false);
p1.Start();
PWM p2 = new PWM(Cpu.PWMChannel.PWM_2, 500, 0.4, false);
p2.Start();
PWM p3 = new PWM(Cpu.PWMChannel.PWM_3, 500, 0.5, false);
p3.Start();
PWM p4 = new PWM(Cpu.PWMChannel.PWM_4, 500, 0.6, false);
p4.Start();
PWM p5 = new PWM(Cpu.PWMChannel.PWM_5, 500, 0.7, false);
p5.Start();
PWM p6 = new PWM(Cpu.PWMChannel.PWM_6, 500, 0.8, false);
p6.Start();
PWM p7 = new PWM(Cpu.PWMChannel.PWM_7, 500, 0.9, false);
p7.Start();
Debug.Print(
Resources.GetString(Resources.StringResources.String1));
Timer t = new Timer (new TimerCallback(TimerTest),"start",200,1000);
Debug.Print("Program started");
Thread.Sleep(Timeout.Infinite);
}
private static void TimerTest(object o)
{
Debug.Print("timer triggered");
}
}
}
So http://wiki.tinyclr.com/index.php?title=FEZ_Cerb40_Developer is the developer page for Cerb40. From that I can see only 4 PWM channels discussed. I’m not sure why you have the number 8 in your mind? The Wiki page you point to is for the FAMILY of devices, not Cerb40; as Aron says the Cerb40 doesn’t say it has all those exposed. Now you’ve found the pinouts, you could add a PWM section to the Cerb40 developer page to help others out.