Skip to main content
Associate
Apr 27, 2025 8:17 AM UTC
Question

Bug with HALL_TIMx_CC_IRQHandler()

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)
...
}

    This topic has been closed for replies.

    2 replies

    GMA
    ST Technical Moderator
    Apr 28, 2025 7:56 AM UTC

    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 'Best answer'.Best regards.GMA
    EMotorManAuthor
    Associate
    May 7, 2025 5:29 AM UTC

    Hi, My version is MotorControl Workbench 6.1.1