Datasheet
Flyport Wi-Fi and Ethernet Programmer's guide framework 2.3 (rev 1.0) www.openpicus.com
PWM function
There are 4 basic PWM functions:
Initialize the pin as PWM →PWMInit(BYTE pwm, float freq, float dutyc);
It is a mandatory to call the initialize function to setup the a PWM module
Parameters:
pwm: PWM id (from 1 up to 9)
freq: the frequency of the PWM signal in Hertz
duty: new duty cycle desired (from 0 up to 100, it is expressed in percentage)
Activate a PWM signal →PWMOn(Byte io, BYTE pwm);
Parameters:
io: io pin to assign at pwm functionality (p1, p2, p3...)
pwm: PWM id (from 1 up to 9)
Change Duty Cycle →PWMDuty(float duty, Byte pwm);
This function can be used to change the pwm duty cycle “on the fly”.
Parameters:
duty: new duty cycle desired (from 0 up to 100, it is expressed in percentage)
pwm: PWM id (from 1 up to 9)
To Turn Off the PWM →PWMOff(BYTE pwm);
This function can be used to turn off a PWM.
Parameters:
pwm: PWM id (from 1 up to 9)
A simple application of PWM can be changing the brightness of a LED. In fact, by changing the PWM
duty cycle we change the root mean square (RMS) voltage of the signal, so we can change the
brightness of a LED with PWM.
For example:
PWMInit(1, 1000, 100); //Initialize PWM1 to work
//at 1000 Hz, 100% of duty (always on)
PWMOn(p5, 1); //Turns on PWM1, and set it to p5
PWMDuty(50, 1); //Change the duty at 50% (about half bright)
PWMDuty(0,1); //Change the duty at 0% (off)
PWMOff(1);
20










