This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem about HAL_setTrigger function.

Other Parts Discussed in Thread: MOTORWARE

I'm using instaspin FOC with motorware 01_01_00_16.

I have a problem about the HAL_setTrigger() function which is different from the previous version code I used.

I think there might be a problem with the code.

When one or two shunts are ignored the offset is calculated as:

offset = pwmCMPAX + cmpOffset;

However when pwmCMPAX has a large value (which should be normal in this situation).

The offset is going to be larger than he period value and the ADC sample could not be triggered in the next cycle.

I think this could be a problem.

Or you intend to do that? Why?

Best,

George

  • The pwmCMPAx value is normally SMALL value for high duty because pwm output setting in hal.c is active high as following.   

          // setup the Action-Qualifier Output A Register (AQCTLA)
          PWM_setActionQual_CntUp_CmpA_PwmA(obj->pwmHandle[cnt],PWM_ActionQual_Set);
          PWM_setActionQual_CntDown_CmpA_PwmA(obj->pwmHandle[cnt],PWM_ActionQual_Clear);

    So, the pwm comparator value is reversed at  HAL_writePwmData() as following.

          pwmData_neg = _IQmpy(pPwmData->Tabc.value[cnt],_IQ(-1.0));

    In other words, the offset value in below code is not going to be larger than the period value if cmpOffset value is not defined with abnormally large value. 

         else if(ignoreShunt == ignore_a)
            {
              offset = pwmCMPA1 + cmpOffset;
            }

    If you set the cmpOffset value too large abnormally, the offset value can be larger than the period and ISR will not be triggered in next cycle as you mentioned. You can also add the following code at the end line of HAL_setTrigger() function to protect this abnormal situation.

      // inhibit unintended pwm output from out of range of the deadband and cmpOffset
      if(pwm1->CMPB >= pwm1->TBPRD) pwm1->CMPB = 0;