diff options
Diffstat (limited to 'src/Platform/Platform.cpp')
-rw-r--r-- | src/Platform/Platform.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp index c9bb41c7..e9dfb10f 100644 --- a/src/Platform/Platform.cpp +++ b/src/Platform/Platform.cpp @@ -2781,10 +2781,8 @@ void Platform::UpdateDriverTimings() noexcept // Convert the step pulse width to clocks of the step pulse gate timer. First define some constants. constexpr uint32_t StepGateTcClockFrequency = (SystemCoreClockFreq/2)/8; constexpr float StepGateClocksPerMicrosecond = (float)StepGateTcClockFrequency/1.0e6; - - const float fclocks = ceilf(worstTimings[0] * StepGateClocksPerMicrosecond); - const uint32_t gateClocks = (uint32_t)fclocks; - STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_RC = gateClocks; + const float fclocks = min<float>(ceilf(worstTimings[0] * StepGateClocksPerMicrosecond), 65535.0); // the TC is only 16 bits wide + STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_RC = (uint32_t)fclocks; // Convert the quantised step pulse width back to microseconds const float actualStepPulseMicroseconds = fclocks/StepGateClocksPerMicrosecond; |