Datasheet
PWM16bit_Change_Duty
321
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub procedure PWM16bit_Change_Duty(dim duty as word, dim channel
as 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