Skip to main content
Associate
April 27, 2025
Question

Bug with HALL_TIMx_CC_IRQHandler()

  • April 27, 2025
  • 1 reply
  • 282 views

file: hall_speed_pos_fdbk.c
function:
There maybe a bug within this code:

if(pHandle->OVFCounter != 0U)
{
if(pHandle->RatioInc)
wCaptBuf = wCaptBuf * (hPrscBuf + 1)
...
else
wCaptBuf = wCaptBuf * (hPrscBuf + 1)
...
}
else
{
if(pHandle->RatioDec)
wCaptBuf = wCaptBuf * (hPrscBuf + 2)
...
else
wCaptBuf = wCaptBuf * (hPrscBuf + 1)
...
}

Consider the following code:

if(pHandle->OVFCounter != 0U)
{
if(pHandle->RatioDec)
wCaptBuf = wCaptBuf * (hPrscBuf + 1) + 0x10000UL
...
else if(pHandle->RatioInc)
wCaptBuf = wCaptBuf * (hPrscBuf + 1) - 0x10000UL
...
else
wCaptBuf = wCaptBuf * (hPrscBuf + 1)
...
}
else
{
if(pHandle->RatioInc)
wCaptBuf = wCaptBuf * (hPrscBuf)
...
else if(pHandle->RatioDec)
wCaptBuf = wCaptBuf * (hPrscBuf + 2)
...
else
wCaptBuf = wCaptBuf * (hPrscBuf + 1)
...
}

    1 reply

    GMA
    Technical Moderator
    April 28, 2025

    Hello @EMotorMan;

    Could you specify the version of the MCSDK you are using?

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

    Hi, My version is MotorControl Workbench 6.1.1