Skip to main content
SRedd.5
Senior III
October 3, 2023
Solved

Hall Speed back fault error

  • October 3, 2023
  • 4 replies
  • 2259 views

I am getting the hall fault in the below code which i have highlighted in red. When i run in open load the below error does not come but only in vehicle condition the fault happens. 

__weak void *HALL_TIMx_CC_IRQHandler(void *pHandleVoid)
{
  uint32_t wCaptBuf;
  uint16_t hPrscBuf;
  uint16_t hHighSpeedCapture;
  HALL_Handle_t *pHandle = (HALL_Handle_t *)pHandleVoid; //cstat !MISRAC2012-Rule-11.5
  TIM_TypeDef *TIMx = pHandle->TIMx;
  uint8_t bPrevHallState;
  int8_t PrevDirection;
 
  if (pHandle->SensorIsReliable)
  {
    /* A capture event generated this interrupt */
    bPrevHallState = pHandle->HallState;
    PrevDirection = pHandle->Direction;
 
    if (DEGREES_120 == pHandle->SensorPlacement)
    {
      pHandle->HallState  = (uint8_t)((LL_GPIO_IsInputPinSet(pHandle->H3Port, pHandle->H3Pin) << 2U)
                                      | (LL_GPIO_IsInputPinSet(pHandle->H2Port, pHandle->H2Pin) << 1U)
                                      | LL_GPIO_IsInputPinSet(pHandle->H1Port, pHandle->H1Pin));
    }
    else
    {
      pHandle->HallState  = (uint8_t)(((LL_GPIO_IsInputPinSet(pHandle->H2Port, pHandle->H2Pin) ^ 1U) << 2U)
                                      | (LL_GPIO_IsInputPinSet(pHandle->H3Port, pHandle->H3Pin) << 1U)
                                      | LL_GPIO_IsInputPinSet(pHandle->H1Port, pHandle->H1Pin));
    }
 
    switch (pHandle->HallState)
    {
      case STATE_5:
      {
        if (STATE_4 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = pHandle->PhaseShift;
        }
        else if (STATE_1 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift + S16_60_PHASE_SHIFT);
}
        else
        {
          /* Nothing to do */
        }
        break;
      }
      case STATE_1:
      {
        if (STATE_5 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = pHandle->PhaseShift + S16_60_PHASE_SHIFT;
 
}
        else if (STATE_3 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift + S16_120_PHASE_SHIFT);
}
        else
        {
          /* Nothing to do */
        }
        break;
      }
 
      case STATE_3:
      {
        if (STATE_1 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift + S16_120_PHASE_SHIFT);
}
        else if (STATE_2 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift + S16_120_PHASE_SHIFT + S16_60_PHASE_SHIFT);
        }
        else
        {
          /* Nothing to do */
        }
        break;
      }
 
      case STATE_2:
      {
        if (STATE_3 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift + S16_120_PHASE_SHIFT + S16_60_PHASE_SHIFT);
 
}
        else if (STATE_6 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift - S16_120_PHASE_SHIFT);
}
        else
        {
          /* Nothing to do */
        }
        break;
      }
 
      case STATE_6:
      {
        if (STATE_2 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift - S16_120_PHASE_SHIFT);
 
}
        else if (STATE_4 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift - S16_60_PHASE_SHIFT);
 
}
        else
        {
          /* Nothing to do */
        }
        break;
      }
 
      case STATE_4:
      {
        if (STATE_6 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift - S16_60_PHASE_SHIFT);
}
        else if (STATE_5 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift);
        }
        else
        {
          /* Nothing to do */
        }
        break;
      }
 
      default:
{
        /* Bad hall sensor configutarion so update the speed reliability */
        pHandle->SensorIsReliable = false;
        break;
      }
    }
 
Fault 2:
Sometimes i get the fault in 
__weak bool SPD_IsMecSpeedReliable(SpeednPosFdbk_Handle_t *pHandle, const int16_t *pMecSpeedUnit)
but both faults does not come when in open load and happens only in vehicle condition. Why?
 
    This topic has been closed for replies.
    Best answer by Gael A

    Hello SRedd.5,

    At first glance, it looks like an issue that has been fixed in MCSDK 6.2, which was released last week. I advise you to upgrade your firmware.
    However, if you can't / don't want to upgrade to MCSDK 6.2, you can take a look at this post : you will find the fix for the issue I am talking about.

    4 replies

    Gael A
    Gael ABest answer
    ST Employee
    October 3, 2023

    Hello SRedd.5,

    At first glance, it looks like an issue that has been fixed in MCSDK 6.2, which was released last week. I advise you to upgrade your firmware.
    However, if you can't / don't want to upgrade to MCSDK 6.2, you can take a look at this post : you will find the fix for the issue I am talking about.

    If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.Hope this will help,Gaël A.
    SRedd.5
    SRedd.5Author
    Senior III
    October 3, 2023

    That is a big relief for me, i have not yet tested but hopefully there are no other serious bugs in the code and it will work fine. I have generated code from 6.2.0 and made modifications only to hall speed feedback code.

    SRedd.5
    SRedd.5Author
    Senior III
    October 10, 2023

    After flashing this software i am also seeing some kind of distortion in waveform in between or small kind of jerks

    SRedd5_0-1696941522540.png

     

    SRedd.5
    SRedd.5Author
    Senior III
    October 12, 2023

    The hall fault still happens once in a while when using the work bench 6.20 but not as frequently as before from the previous work bench software's. This is observed in vehicle trails. Any other code updates to be done?

    SRedd.5
    SRedd.5Author
    Senior III
    October 12, 2023

    I think the mistake is from my end where the hall signals are going to hall state7 which is invalid, something to do with hardware. Regarding the initial slow ramp i increased the Kp and it starts little bit smooth. Thank you very much support.