User manual

Table Of Contents
402
mikoC PRO for PIC32
MikroElektronika
PWM_Set_Duty
Prototype
void PWM_Set_Duty(unsigned duty, unsigned channel);
Description The function changes PWM duty ratio.
Parameters - duty: PWM duty ratio. Valid values: 0 to timer period returned by the PWM_Init function.
- channel: number of PWM channel to change duty to.
Returns Nothing.
Requires MCU must have the HW PWM Module.
PWM channel must be properly initialized. See PWM_Init routine.
Example
// Set channel 1 duty ratio to 50%:
unsigned int pwm_period1;
...
PWM_Set_Duty(pwm_period1/2, 1);
Notes Number of available PWM channels depends on MCU. Refer to MCU datasheet for details.
PWM_Start
Prototype
void PWM_Start(unsigned int enable_channel_x);
Description Starts PWM at requested channel.
Parameters - enable_channel_x: number of PWM channel
Returns Nothing.
Requires MCU must have the HW PWM Module.
PWM channel must be properly congured. See the PWM_Init and PWM_Set_Duty routines.
Example
// start PWM at channel 1
PWM_Start(1);
Notes Number of available PWM channels depends on MCU. Refer to MCU datasheet for details.
PWM_Stop
Prototype
void PWM_Stop(unsigned int disable_channel_x);
Description Stops PWM at requested channel.
Parameters - disable_channel_x: number of PWM channel
Returns Nothing.
Requires MCU must have the HW PWM Module.
Example
// stop PWM at channel 1
PWM_Stop(1);
Notes Number of available PWM channels depends on MCU. Refer to MCU datasheet for details.