User manual
mikroC PRO for dsPIC
MikroElektronika
463
PWMx_Mc_Stop
Prototype
void PWMx_Mc_Stop();
Description Stops the Motor Control PWM module.
Parameters None.
Returns Nothing.
Requires The dsPIC30/33 MCU must have the Motor Control PWM module.
Example
// stop the Motor Control PWM1 module
PWM1_Mc_Stop();
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.
Library Example
The example changes PWM duty ratio on channel 1 continually. If LED is connected to the channel 1, a gradual change
of emitted light will be noticeable.
Copy Code To Clipboard
unsigned int i;
unsigned int duty_50;
void main(){
ADPCFG = 0xFFFF; // initialize AN pins as digital
PORTB = 0xAAAA;
TRISB = 0; // initialize portb as output
Delay_ms(1000);
duty_50 = PWM1_MC_Init(5000, 0, 0x01, 0); // Pwm_Mc_Init returns 50% of the
duty
PWM1_MC_Set_Duty(i = duty_50, 1);
PWM1_MC_Start();
do
{
i--;
PWM1_MC_Set_Duty(i, 1);
Delay_ms(10);
if (i == 0)
i = duty_50 * 2 - 1; // Let us not allow the overow
PORTB = i;
}
while(1);
}