(Bug Report) Dual drive code appears in R3_2_TIMx_UP_IRQHandler() / r3_2_f4xx_pwm_curr_fdbk.c when using single drive configuration
(Environment)
MC_SDK 5.Y.3 + STM32CubeMX 6.3.0 with HAL + IAR EWARM 8.5
(Hardware)
custom board based on F446RE + custom power board + Low Voltage BLDC motor with Encoder
(Control Mode)
Speed Control
(What I found)
- I configured a single drive, where TIM1(PWM), TIM2(Encoder), ADC1/2(Current Feedback) are used.
- In R3_2_TIMx_UP_IRQHandler(), there are some lines commented as "dual drive check".
==========================================================================
/* dual drive check */
ADCInjFlags = ADCx_1->SR & (LL_ADC_FLAG_JSTRT|LL_ADC_FLAG_JEOS);
if ( ADCInjFlags == LL_ADC_FLAG_JSTRT )
{
/* ADC conversion is on going on the second motor */
do
{
/* wait for end of conversion */
ADCInjFlags = ADCx_1->SR & (LL_ADC_FLAG_JSTRT|LL_ADC_FLAG_JEOS);
}
while ( ADCInjFlags != (LL_ADC_FLAG_JSTRT|LL_ADC_FLAG_JEOS) );
}
else if ( ADCInjFlags == 0 )
{
/* ADC conversion on the second motor is not yet started */
while ( ( TIMx->CNT ) < ( pHandle->pParams_str->Tw ) )
{
/* wait for a maximum delay */
}
ADCInjFlags = ADCx_1->SR & (LL_ADC_FLAG_JSTRT|LL_ADC_FLAG_JEOS);
if ( ADCInjFlags == LL_ADC_FLAG_JSTRT )
{
/* ADC conversion is on going on the second motor */
do
{
/* wait for end of conversion */
ADCInjFlags = ADCx_1->SR & (LL_ADC_FLAG_JSTRT|LL_ADC_FLAG_JEOS);
}
while ( ADCInjFlags != (LL_ADC_FLAG_JSTRT|LL_ADC_FLAG_JEOS) );
}
}
else
{
/* ADC conversion on the second motor is done */
}
==========================================================================
- Actually, in the above code, "else if(ADCInjFlags==0) { }" is always executed, then it is blocked in while() for (wait for a maximum delay).
(Question)
- Is that a defect or a intended function?
- If a defect, is it good enough to remove the above code?
