User manual
364
mikoPascal PRO for PIC32
MikroElektronika
PWM_Set_Duty
Prototype
procedure PWM_Set_Duty(duty, channel : word);
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%:
var pwm_period1 : word;
...
PWM_Set_Duty(pwm_period1 div 2, 1);
Notes Number of available PWM channels depends on MCU. Refer to MCU datasheet for details.
PWM_Start
Prototype
procedure PWM_Start(enable_channel_x : byte);
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
procedure PWM_Stop(disable_channel_x : byte);
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.