User manual
374
mikoBasic PRO for PIC32
MikroElektronika
PWM_Set_Duty
Prototype
sub procedure PWM_Set_Duty(dim duty, channel as 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%:
dim pwm_period1 as 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
sub procedure PWM_Start(dim enable_channel_x as 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 congured. 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
sub procedure PWM_Stop(dim disable_channel_x as 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.