Skip to main content
THA.1
Associate III
December 16, 2021
Solved

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

  • December 16, 2021
  • 4 replies
  • 1132 views

(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?
This topic has been closed for replies.
Best answer by GMA

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

4 replies

THA.1
THA.1Author
Associate III
December 29, 2021

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

THA.1
THA.1Author
Associate III
January 18, 2022

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

GMA
GMABest answer
Technical Moderator
January 19, 2022

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
THA.1Author
Associate III
January 19, 2022

Thank you for your confirmation !

Regards.

THA