Datasheet

375
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
Description
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)
PWM_Init must be called before using other functions from PWM Library.
Requires
You need a CMO on the given MCU (that supports PWM).
Before calling this routine you must set the output pin for the PWM (according to
the datasheet):
DDRB.3 = 1; // set PORTB pin 3 as output for the PWM
This code oxample is for ATmega16, for different MCU please consult datasheet
for the correct pinout of the PWM module or modules.
Example
Initialize PWM module:
PWM_Init(_PWM_FAST_MODE, _PWM_PRESCALER_8, _PWM_NON_INVERTED,
127);