diff --git a/hal/src/main/native/athena/DIO.cpp b/hal/src/main/native/athena/DIO.cpp index e6308fbb75..57b115384e 100644 --- a/hal/src/main/native/athena/DIO.cpp +++ b/hal/src/main/native/athena/DIO.cpp @@ -200,8 +200,7 @@ void HAL_SetDigitalPWMRate(double rate, int32_t* status) { if (*status != 0) { return; } - uint16_t pwmPeriodPower = - std::lround(std::log(1.0 / (16 * 1.0E-6 * rate)) / std::log(2.0)); + uint16_t pwmPeriodPower = std::lround(std::log2(1.0 / (16 * 1.0E-6 * rate))); digitalSystem->writePWMPeriodPower(pwmPeriodPower, status); } diff --git a/hal/src/main/native/sim/DIO.cpp b/hal/src/main/native/sim/DIO.cpp index b611b35e8a..f827bbf956 100644 --- a/hal/src/main/native/sim/DIO.cpp +++ b/hal/src/main/native/sim/DIO.cpp @@ -127,9 +127,7 @@ void HAL_SetDigitalPWMRate(double rate, int32_t* status) { // higher freq. // TODO: Round in the linear rate domain. // uint8_t pwmPeriodPower = static_cast( - // std::log(1.0 / (kExpectedLoopTiming * 0.25E-6 * rate)) / - // std::log(2.0) + - // 0.5); + // std::log2(1.0 / (kExpectedLoopTiming * 0.25E-6 * rate)) + 0.5); // TODO(THAD) : Add a case to set this in the simulator // digitalSystem->writePWMPeriodPower(pwmPeriodPower, status); }