Page 1 of 1
STM32F4 PWM Hal interrupt config error
Posted: Sat Sep 13, 2014 10:23 pm
by tecnologic
HI again,
seems i am the only one using the ADC and pwm drivers on Stm32 at maximum.
in the TIMv1 driver this line is missing when configuring registers
Code: Select all
pwmp->tim->DIER = pwmp->config->dier; /* DIER settings. */
regards
Tec
Re: STM32F4 PWM Hal interrupt config error
Posted: Sun Sep 14, 2014 8:54 am
by Giovanni
Hi,
Fixed as big #534, there was a similar problem in the ICU driver too.
Giovanni
Re: STM32F4 PWM Hal interrupt config error
Posted: Mon Sep 15, 2014 10:19 pm
by tecnologic
Hi Giovanni,
i found one small copy and paste error within the bugfix
line 610 of pwm_lld. is
Code: Select all
pwmp->tim->DIER = pwmp->config->dier & /* DMA-related DIER settings. */
~STM32_TIM_DIER_IRQ_MASK
which kills the settigns of dier with
, removing the ~ solves the problem.
Regards
Tec
Re: STM32F4 PWM Hal interrupt config error
Posted: Mon Sep 15, 2014 11:16 pm
by Giovanni
It is intentional, you are not supposed to enable interrupts by yourself using DIER, that setting is only for DMAs. Interrupts are enabled by pwmEnableChannel(). However there was another problem preventing the periodic callback.
Committed a fix but will test tomorrow, it's to late now.
Code: Select all
/**
* @brief TIM DIER register initialization data.
* @note The value of this field should normally be equal to zero.
* @note Only the DMA-related bits can be specified in this field.
*/
uint32_t dier;
Giovanni
Re: STM32F4 PWM Hal interrupt config error
Posted: Tue Sep 16, 2014 7:16 am
by tecnologic
Ok, i miss interpreted this setting. I will pull the changes in the evening and test them on my HW.
Thanks
Re: STM32F4 PWM Hal interrupt config error
Posted: Tue Sep 16, 2014 6:57 pm
by tecnologic
Code: Select all
/* Changing channel duty cycle on the fly.*/
#if STM32_TIM_MAX_CHANNELS <= 4
pwmp->tim->CCR[channel] = width;
+ pwmp->tim->DIER |= (2 << channel);
#else
if (channel <= 4)
pwmp->tim->CCR[channel] = width;
+ pwmp->tim->DIER |= (2 << channel);
else
pwmp->tim->CCXR[channel - 4] = width;
+ pwmp->tim->DIER |= (2 << (channel - 4));
#endif
}
This fix in pwm_lld_enable was missing. with that it works.
@OffTopic: i tested the QEI driver posted in the forum some weeks ago, it works fine for me out of the box. with an 10000 step quad encoder. may be it can be added to the hal?
Regards
Tec
Re: STM32F4 PWM Hal interrupt config error
Posted: Tue Sep 16, 2014 7:21 pm
by Giovanni
Hi,
In 3.0 the API changed, the notifications have to be explicitly enabled by calling pwmEnablePeriodicNotification(), the function pwmEnableChannel() does not enable notifications by itself. Example:
Code: Select all
pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 7500));
pwmEnableChannelNotification(&PWMD1, 0);
The point of the change is to be able to run very fast PWMs and, only when needed, enable the callback, synchronize with the front and then disable the callback again.
In the old model interrupts were always enabled if callbacks were defined, that was bad because all the interrupts.
Functions added:
Code: Select all
void pwmEnablePeriodicNotification(PWMDriver *pwmp);
void pwmDisablePeriodicNotification(PWMDriver *pwmp);
void pwmEnableChannelNotification(PWMDriver *pwmp, pwmchannel_t channel);
void pwmDisableChannelNotification(PWMDriver *pwmp, pwmchannel_t channel);
Giovanni
Re: STM32F4 PWM Hal interrupt config error
Posted: Tue Sep 16, 2014 10:10 pm
by tecnologic
OH Ok,
Changed and works.
Thanks for the hint.