Main Site Documentation

G120 pwm


#1

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: http://wiki.tinyclr.com/index.php?title=G120HDR_Developer


#2

Welecome to forum.

You can code the pin number directly. Look at http://wiki.tinyclr.com/index.php?title=G120HDR_Developer for guidence on calculating the pin number.

(Cpu.Pin)31 for pin 31


#3

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