Interrupt on PWM output?

HI,

I would like to create two synchronized PWM’s with a fixed offset on Panda III:

 static PWM Pwm1 = new PWM(FEZPandaIII.PwmOutput.D9, 5000, 110, PWM.ScaleFactor.Microseconds, false);
 static PWM Pwm2 = new PWM(FEZPandaIII.PwmOutput.D6, 5000, 110, PWM.ScaleFactor.Microseconds, false);

and in Main:

InterruptPort Pwm1Int = 
                new InterruptPort(FEZPandaIII.Gpio.D9, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);
            Pwm1Int.OnInterrupt += StartPwm2;

However, there is always an exception thrown by Microsoft.SPOT.Hardware.dll and the Start_Pwm2 never gets called.

Is this a Panda defect?

D

An InterruptPort will try to initialize the pin as an Input port. But the PWM already configured it as an (PWM)Output.
1st: you can not initialize the same pin twize.
2nd: you can not use Interrupts with Outputs.

You could connect the Output pin physically to any other Interrupt capable pin and create the InterruptPort for this one.

1 Like