G120 pwm

Hello,

i have a question. How to use all PWM channels on G120?

The enumeration Cpu.PWMChannel doesnt contains the channel for pin P3.26. Enum ends on channel PWM_7.


RedLed = new PWM(Cpu.PWMChannel.PWM_6, _freq, 0.5, false); //RGB Led P3.24
GreenLed = new PWM(Cpu.PWMChannel.PWM_7, 0.5, false); //RGB Led P3.25
BlueLed = new PWM(???, _freq, 0.5, false); //RGB Led P3.26 

I used this as reference: GHI Electronics – Where Hardware Meets Software

Welecome to forum.

You can code the pin number directly. Look at Home - GHI Electronics for guidence on calculating the pin number.

(Cpu.Pin)31 for pin 31

Thanks for quick answer,

but the PWM constructor needs type Cpu.PWMChannel.

The PWMChannel num 8 and higher aren’t defined in Microsoft.SPOT.Hardware;

This works:


(Cpu.PWMChannel)8