cancel
Showing results for 
Search instead for 
Did you mean: 

Bug with HALL_TIMx_CC_IRQHandler()

EMotorMan
Associate

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

2 REPLIES 2
GMA
ST Employee

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

Hi, My version is MotorControl Workbench 6.1.1