User`s manual

CCP (Capture/ Compare/ PWM) module is available with a number of PIC MCU
models. Set of library procedures and functions is listed below to provide comfort-
able work with PWM (Pulse Width Modulation).
Note that these routines support module on PORTC pin RC2, and won't work with
modules on other ports. Also, mikroBasic doesn't support enhanced PWM mod-
ules. Examples for PIC MCUs with module on other ports can be found in your
mikroBasic installation folder, subfolder 'examples'.
sub procedure PWM_Init(const PWM_Freq)
sub procedure PWM_Change_Duty(dim New_Duty as byte)
sub procedure PWM_start
sub procedure PWM_stop
procedure PWM_Init(const PWM_Freq);
Initializes the PWM module. It starts with (duty ratio) 0%.
Parameter PWM_Freq is a desired PWM frequency (refer to device data sheet for
correct values in respect with Fosc).
Example:
PWM_Init(5000);
sub procedure PWM_Change_Duty(dim New_Duty as byte)
Parameter New_Duty (duty ratio) takes values from 0 to 255, where 0 is 0% duty
ratio, 127 is 50% duty ratio, and 255 is 100% duty ratio. Other values for specific
duty ratio can be calculated as (Percent*255)/100.
sub procedure PWM_start
Starts PWM.
sub procedure PWM_stop
Stops PWM.
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
148
mikroBASIC
MikroElektronika: Development tools - Books - Compilers
PWM Library
Note
Routines
making it simple...
page