|
|
View previous topic :: View next topic |
Author |
Message |
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
How to use #use pwm() |
Posted: Thu Jun 24, 2021 1:32 am |
|
|
How to use #use pwm() on devices with multiple independent PWMs ?
For example: is it possible to apply this directive for separate control of PWM1, PWM2, PWM3, PWM4 ? And if so, then how exactly to do it for BIF pwm_off() and pwm_on() ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
|
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
|
Posted: Thu Jun 24, 2021 3:20 am |
|
|
Code: |
#use delay ( clock = 16000000 )
#USE PWM(CCP1, OUTPUT=PIN_C1, TIMER=2, FREQUENCY=10kHz, DUTY=50, PWM_OFF, STREAM=1)
#USE PWM(PWM3, OUTPUT=PIN_C2, TIMER=4, FREQUENCY=5kHz, DUTY=25, PWM_OFF, STREAM=2)
#USE PWM(PWM4, OUTPUT=PIN_C3, TIMER=6, FREQUENCY=3.33kHz, DUTY=16.6, PWM_OFF, STREAM=3)
// for example
void main(void)
{
pwm_on (1);
pwm_on (2);
pwm_off (3);
delay_ms (20);
pwm_off (1);
pwm_off (2);
pwm_on (3);
while(TRUE)
{}
}
|
is it right? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Thu Jun 24, 2021 3:55 am |
|
|
Stream names, need to be unique names, not just numbers.
Without knowing what chip you are using, can't know if it supports
the pins and timers you are specifying. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|