G120 PWMs not individually controllable

I am attempting to put different frequencies and duty cycles on several PWM outputs on the G120. When I command one, however, it affects the others. I verified there was no short between the pins, and wrote a small app to verify their actions.

namespace NetMfTest3
{
    public class Program
    {
        static InterruptPort button = new InterruptPort(GHI.Pins.G120.P0_3, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
        static int step = 0;
        static PWM crank = new PWM((Cpu.PWMChannel)8, 9000, .5, false);
        static PWM knock = new PWM(Cpu.PWMChannel.PWM_7, 5000, .5, false);
        static PWM ap = new PWM(Cpu.PWMChannel.PWM_6, 100, .5, false);

        static void button_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            step++;
            if (step > 2) step = 0;
            SetOutput(step);
        }

        static void SetOutput(int number)
        {
            switch (number)
            {
                case 0:
                    crank.Frequency = 9000;
                    Debug.Print("Crank = 9000");
                    break;

                case 1:
                    knock.Frequency = 5000;
                    Debug.Print("Knock = 5000");
                    break;

                case 2:
                    ap.Frequency = 100;
                    Debug.Print("ap = 100");
                    break;
            }
        }

        public static void Main()
        {
            button.OnInterrupt += button_OnInterrupt;
            crank.Start();
            knock.Start();
            ap.Start();
            Debug.Print("Program started.");
            Thread.Sleep(-1);
        }
    }
}

Each time I press the button it sets a different PWM output but all the outputs are changed. WHY?!!!

Some pwm signals share the same source clock. The updated datasheet, coming this week, shows the individual pins.

You can also check the lpc1788 datasheet from nxp today to see which pins are on the same clock.

Understood. I did check the user manual for the G120 pretty thoroughly and it says NOTHING about shared clocks. I’ll find a work around, but this is very frustrating.

Normally you can set dividers for various PWM outputs that share a clock and get different frequencies, at least if you are working at a lower level than NetMF. Is there any way to do this in NetMF?

You could use the Register class to access the registers directly or you could use RLP.

@ bigtwisty - like I said. This info is in the new datasheet coming this week, not available today, or check the lpc1788 datasheet from nxp instead today.

Accessing the registers directly still not change the outcome.

…I will try to dig these up for you when back at the office.

With three little kids, I have few free seconds to help but I keep trying :wall:

Thank you for the help, Gus. I understand that this will be in the upcoming data sheet. I just would have thought that with the G120 having been around as long as it has, something fairly key like shared clocks on PWM outputs would have made it into the customer facing documentation by now.

Please don’t think my frustration is with you, or that I don’t appreciate your assistance on a Sunday!