Datasheet

PWM16bit_Change_Duty
PWM16bit_Start
334
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
procedure PWM16bit_Change_Duty(duty : word; channel : byte);
Returns Nothing.
Description
Changes PWM duty ratio. Parameter duty takes values shown on the table
below. Where 0 is 0%, and TOP value is 100% duty ratio. Other specific values
for duty ratio can be calculated as (Percent*TOP)/100.
Requires
PWM module must to be initialised (PWM16bit_Init) before using
PWM_Set_Duty function.
Example
Example lets set duty ratio to :
PWM16bit_Change_Duty(300, _TIMER1_CH_A );
Timer/Counter Mode of
Operation :
TOP :
Update of
OCRnX at :
TOVn Flag Set
on :
PWM, Phase Correct, 8 bit 0x00FF TOP BOTTOM
PWM, Phase Correct, 9 bit 0x01FF TOP BOTTOM
PWM, Phase Correct, 10 bit 0x03FF TOP BOTTOM
Fast PWM, 8 bit 0x00FF TOP TOP
Fast PWM, 9 bit 0x01FF TOP TOP
Fast PWM, 10 bit 0x03FF TOP TOP
Prototype
procedure PWM16bit_Start(timer : byte);
Returns Nothing.
Description
Starts PWM-16bit module with alredy preset values (wave mode, prescaler,
inverted and duty) given in the PWM16bit_Init.
Requires
MCU must have CMO module to use this library. PWM16bit_Init must be called
before using this routine, otherwise it will have no effect as the PWM module is
not initialised.
Example
PWM16bit_Start(_TIMER1 ); // Starts the PWM-16bit module
on Timer/Counter1 or
PWM16bit_Start(_TIMER3 ); // Starts the PWM-16bit module
on Timer/Counter3