Datasheet
Note: Not all of the MCUs have both PWM and PWM1 library included. Sometimes, like its the
case with ATmega8515, MCU has only PWM library. Therefore constants that have in their name
PWM1 are invalid (for ATmega8515) and will not be visible from Code Assistant. It is highly advis-
able to use this feature, since it handles all the constants (available) nad eliminates any chance
of typing error.
PWM_Init
374
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
Prototype
void PWM_Init(unsigned short wave_mode, unsigned short prescaler,
unsigned short inverted, unsigned short duty);
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.
The N variable represents the
prescaler factor (1, 8, 64, 256, or 1024). Some
modules also support 32 and 128 prescaler value, but for this you will need to
check the datasheet for the desired MCU)