Skip to content

Commit

Permalink
Fixed overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jsphuebner committed Sep 30, 2024
1 parent 6ff6f73 commit a8dd934
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pwmgeneration-foc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static int32_t GenerateAntiCoggingSignal(uint16_t angle, s32fp coggingCurrent)

uint16_t antiCog = 4 * angle;
int32_t antiCogScaled = ((int32_t)antiCog) - 32767;
antiCogScaled = FP_TOINT((antiCogScaled * FP_MUL(coggingCurrent, Param::Get(Param::cogkp))) / 65536);
antiCogScaled = (antiCogScaled * FP_TOINT(coggingCurrent) * Param::GetInt(Param::cogkp)) / 65536;

return antiCogScaled;
}

0 comments on commit a8dd934

Please sign in to comment.