Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2022-07-05 00:58:48 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-07-05 00:58:48 +0300
commit88b925276f2b81b9daf2c0c95b08fe47634bc7fa (patch)
tree438ac5b63ee9075309462d12f6f7e01bdbfac9e7
parent243be4d5d2895dd650a0eab55d9932b5b60291bb (diff)
Limit step pulse width on MB6XD to take account of 16-bit timer
-rw-r--r--src/Platform/Platform.cpp6
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;