Mikroelektronika MIKROE-350 Data Sheet

Page of 526
PWM_Init
310
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub procedure PWM_Init(dim wave_mode as bytedim prescaler as
byte
dim inverted as bytedim duty as byte)
Returns
Nothing.
Description
Initializes the PWM module. Parameter wave_mode is a desired PWM mode.
There are two modes: Phase Correct and Fast PWM. Parameter prescaler
chooses prescale value N = 1,8,64,256 or 1024 (some modules support 32 and
128, but for this you will need to check the datasheet for the desired MCU).
Paremeter inverted is for choosing between inverted and non inverted PWM
signal. Parameter duty sets duty ratio from 0 to 255. PWM signal graphs and
formulas are shown below.
PWM_Init must be called before using other functions from PWM Library.