cancel
Showing results for 
Search instead for 
Did you mean: 

(Bug Report) Dual drive code appears in R3_2_TIMx_UP_IRQHandler() / r3_2_f4xx_pwm_curr_fdbk.c when using single drive configuration

THA.1
Associate II

(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?
1 ACCEPTED SOLUTION

Accepted Solutions
GMA
ST Employee

Hello,

You are fully right. This part of the code covers single and dual motors as well.

The Dual Drive part is useless for single motor but doesn't prevent single drive to work.

Yes you can remove the above code.

Best regards.

Gilbert

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA

View solution in original post

4 REPLIES 4
THA.1
Associate II

I added the corresponding code lines in the question details. Someone can answer this please?

THA.1
Associate II

Could ST test this case and guide how to handle the code?​

GMA
ST Employee

Hello,

You are fully right. This part of the code covers single and dual motors as well.

The Dual Drive part is useless for single motor but doesn't prevent single drive to work.

Yes you can remove the above code.

Best regards.

Gilbert

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA
THA.1
Associate II

Thank you for your confirmation !

Regards.

THA