Hello,
I have a small module that uses two channels on the PWM5.
I would like to be able to modify the duty cycle of one of these two channels.
My problem is that when i modify the duty cycle of one channel, the second channel is resetted.
To modify the duty cycle, i use the function pwmEnableChannel.
I think it is the culprit that disable the second PWM.
Is there another function under Chibios to change the duty cycle without interfering with another channel ?
Or do i have to play with the TIM5_CCRx registers ?
Thank you in advance.
Stephane
Change PWM duty cycle
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Change PWM duty cycle
Hi,
pwmEnableChannel() only touches the CCR register, this should not happen but it happens because a stupid bug in this code...
I imagine you are using an STM32F3, correct?
Opened a ticket: https://sourceforge.net/p/chibios/bugs/722/
Will be fixed in 16.1.4 (next weekend).
Giovanni
pwmEnableChannel() only touches the CCR register, this should not happen but it happens because a stupid bug in this code...
I imagine you are using an STM32F3, correct?
Code: Select all
void pwm_lld_enable_channel(PWMDriver *pwmp,
pwmchannel_t channel,
pwmcnt_t width) {
/* Changing channel duty cycle on the fly.*/
#if STM32_TIM_MAX_CHANNELS <= 4
pwmp->tim->CCR[channel] = width;
#else
if (channel <= 4)
pwmp->tim->CCR[channel] = width;
else
pwmp->tim->CCXR[channel - 4] = width;
#endif
}
Opened a ticket: https://sourceforge.net/p/chibios/bugs/722/
Will be fixed in 16.1.4 (next weekend).
Giovanni
Re: Change PWM duty cycle
Hello again,
I have to confess that i found a misplaced pwmStart() on my code...
On my case, with Chibios 3.0.0, the pwmEnableChannel() routine seems to work correctly.
With best regards,
Stéphane
I have to confess that i found a misplaced pwmStart() on my code...
On my case, with Chibios 3.0.0, the pwmEnableChannel() routine seems to work correctly.
With best regards,
Stéphane