Mikroelektronika MIKROE-350 データシート

ページ / 526
313
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic 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)
PWM1_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):
DDRD.7 = 1; // set PORTD pin 7 as output for the PWM1 
This code oxample is for ATmega16 (second PWM module), for different MCU
please consult datasheet for the correct pinout of the PWM module or modules.
Example
Initialize PWM module:
PWM1_Init(_PWM1_FAST_MODE, _PWM1_PRESCALER_8, _PWM1_NON_INVERTED,
127)