Mikroelektronika MIKROE-724 データシート

ページ / 726
438
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
PWMx_Mc_Set_Duty
PWMx_Mc_Start
Prototype
sub procedure PWM1_Mc_Set_Duty(dim duty, channel as word)
‘ For dsPIC 33FJ MCUs that have PWM2 module :
sub procedure PWM2_Mc_Set_Duty(dim duty as word) 
Description The function changes PWM duty ratio.
Parameters 
duty
: PWM duty ratio. Valid values: 
0
 to timer period returned by the PWMx_Mc_Init function. 
channel
: number of PWM channel to change duty to.
Returns
Nothing.
Requires
The dsPIC30/33 MCU must have the Motor Control PWM module.
The PWM module needs to be initalized. See the PWMx_Mc_Init function.
Example
‘ Set duty ratio to 50% at channel 1:
PWM1_Mc_Init(5000,1,$F,0)
...
PWM1_Mc_Set_Duty(32767, 1)
Notes
- Number of PWM modules per MCU differs from chip to chip. Please, read the appropriate datasheet 
before utilizing this library. 
- PWM library routines require you to specify the module you want to use. To use the desired PWM 
module, simply change the letter 
x in the routine prototype for a number from 1 to 2
Prototype
sub procedure PWMx_Mc_Start()
Description Starts the Motor Control PWM module (channels initialized in the PWMx_Mc_Init function).
Parameters None.
Returns
Nothing.
Requires
The dsPIC30/33 MCU must have the Motor Control PWM module.
The PWM module needs to be initalized. See the PWMx_Mc_Init function.
Example
‘ start the Motor Control PWM1 module
PWM1_Mc_Start()
Notes
- Number of PWM modules per MCU differs from chip to chip. Please, read the appropriate datasheet 
before utilizing this library. 
- PWM library routines require you to specify the module you want to use. To use the desired PWM 
module, simply change the letter 
x in the routine prototype for a number from 1 to 2