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 12:57:20 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-07-05 12:57:20 +0300
commit02bdc0f3527fdf52b8a2f7142120ed7072630f89 (patch)
tree438ac5b63ee9075309462d12f6f7e01bdbfac9e7
parent878226960fb45a5dabfb27309fadf088f096065b (diff)
Revert "Support longer step pulses on MB6XD when in test mode"
This reverts commit 878226960fb45a5dabfb27309fadf088f096065b.
-rw-r--r--src/CAN/CanInterface.cpp3
-rw-r--r--src/Platform/Platform.cpp47
-rw-r--r--src/Platform/Platform.h4
3 files changed, 20 insertions, 34 deletions
diff --git a/src/CAN/CanInterface.cpp b/src/CAN/CanInterface.cpp
index 94aabd0c..b7827e4d 100644
--- a/src/CAN/CanInterface.cpp
+++ b/src/CAN/CanInterface.cpp
@@ -332,9 +332,6 @@ void CanInterface::SwitchToExpansionMode(CanAddress addr, bool useTestMode) noex
inExpansionMode = true;
inTestMode = useTestMode;
reprap.GetGCodes().SwitchToExpansionMode();
-#ifdef DUET3_MB6XD
- reprap.GetPlatform().InitStepGateTimer(); // change the step gate timer to allow longer pulses for ATE
-#endif
ReInit(); // reset the CAN filters to account for our new CAN address
}
diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp
index 82bb839c..e9dfb10f 100644
--- a/src/Platform/Platform.cpp
+++ b/src/Platform/Platform.cpp
@@ -647,7 +647,19 @@ void Platform::Init() noexcept
#ifdef DUET3_MB6XD
driverErrPinsActiveLow = (numErrorHighDrivers >= NumDirectDrivers/2); // determine the error signal polarity by assuming most drivers are not in the error state
- InitStepGateTimer();
+
+ // Set up the step gate timer
+ pmc_enable_periph_clk(STEP_GATE_TC_ID);
+ STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_CCR = TC_CCR_CLKDIS;
+ STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_CMR = TC_CMR_BSWTRG_SET // software trigger sets TIOB
+ | TC_CMR_BCPC_CLEAR // RC compare clears TIOB
+ | TC_CMR_WAVE // waveform mode
+ | TC_CMR_WAVSEL_UP // count up
+ | TC_CMR_CPCSTOP // counter clock is stopped when counter reaches RC
+ | TC_CMR_EEVT_XC0 // set external events from XC0 (this allows TIOB to be an output)
+ | TC_CMR_TCCLKS_TIMER_CLOCK2; // divide MCLK (150MHz) by 8 = 18.75MHz
+ SetPinFunction(StepGatePin, StepGatePinFunction);
+ STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_CCR = TC_CCR_CLKEN;
#endif
// Set up the axis+extruder arrays
@@ -693,7 +705,9 @@ void Platform::Init() noexcept
#endif
}
-#ifndef DUET3_MB6XD
+#ifdef DUET3_MB6XD
+ UpdateDriverTimings();
+#else
for (uint32_t& entry : slowDriverStepTimingClocks)
{
entry = 0; // reset all to zero as we have no known slow drivers yet
@@ -2749,27 +2763,6 @@ GCodeResult Platform::SetMotorCurrent(size_t axisOrExtruder, float currentOrPerc
#ifdef DUET3_MB6XD
-// Set up the step gate timer. We reduce the speed to allow longer pulses when in test mode.
-void Platform::InitStepGateTimer() noexcept
-{
- pmc_enable_periph_clk(STEP_GATE_TC_ID);
- STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_CCR = TC_CCR_CLKDIS;
- const uint32_t clockDiv = (CanInterface::InTestMode())
- ? TC_CMR_TCCLKS_TIMER_CLOCK3 // divide MCLK (150MHz) by 32 = 4.6875MHz
- : TC_CMR_TCCLKS_TIMER_CLOCK2; // divide MCLK (150MHz) by 8 = 18.75MHz
- STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_CMR = TC_CMR_BSWTRG_SET // software trigger sets TIOB
- | TC_CMR_BCPC_CLEAR // RC compare clears TIOB
- | TC_CMR_WAVE // waveform mode
- | TC_CMR_WAVSEL_UP // count up
- | TC_CMR_CPCSTOP // counter clock is stopped when counter reaches RC
- | TC_CMR_EEVT_XC0 // set external events from XC0 (this allows TIOB to be an output)
- | clockDiv; // divide MCLK (150MHz) by 8 or 32
- SetPinFunction(StepGatePin, StepGatePinFunction);
- STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_CCR = TC_CCR_CLKEN;
-
- UpdateDriverTimings();
-}
-
// Fetch the worst (longest) timings of any driver, set up the step pulse width timer, and convert the other timings from microseconds to step clocks
void Platform::UpdateDriverTimings() noexcept
{
@@ -2786,8 +2779,8 @@ void Platform::UpdateDriverTimings() noexcept
}
// Convert the step pulse width to clocks of the step pulse gate timer. First define some constants.
- const uint32_t StepGateTcClockFrequency = (CanInterface::InTestMode()) ? (SystemCoreClockFreq/2)/32 : (SystemCoreClockFreq/2)/8;
- const float StepGateClocksPerMicrosecond = (float)StepGateTcClockFrequency/1.0e6;
+ constexpr uint32_t StepGateTcClockFrequency = (SystemCoreClockFreq/2)/8;
+ constexpr float StepGateClocksPerMicrosecond = (float)StepGateTcClockFrequency/1.0e6;
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;
@@ -2804,8 +2797,8 @@ void Platform::UpdateDriverTimings() noexcept
void Platform::GetActualDriverTimings(float timings[4]) noexcept
{
- const uint32_t StepGateTcClockFrequency = (CanInterface::InTestMode()) ? (SystemCoreClockFreq/2)/32 : (SystemCoreClockFreq/2)/8;
- const float MicrosecondsPerStepGateClock = 1.0e6/(float)StepGateTcClockFrequency;
+ constexpr uint32_t StepGateTcClockFrequency = (SystemCoreClockFreq/2)/8;
+ constexpr float MicrosecondsPerStepGateClock = 1.0e6/(float)StepGateTcClockFrequency;
constexpr float StepClocksToMicroseconds = 1.0e6/(float)StepClockRate;
timings[0] = (float)STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_RC * MicrosecondsPerStepGateClock;
timings[1] = stepPulseMinimumPeriodClocks * StepClocksToMicroseconds - timings[0];
diff --git a/src/Platform/Platform.h b/src/Platform/Platform.h
index 518a26ee..a8ae2c27 100644
--- a/src/Platform/Platform.h
+++ b/src/Platform/Platform.h
@@ -680,10 +680,6 @@ public:
void OnProcessingCanMessage() noexcept; // called when we start processing any CAN message except for regular messages e.g. time sync
#endif
-#ifdef DUET3_MB6XD
- void InitStepGateTimer() noexcept;
-#endif
-
protected:
DECLARE_OBJECT_MODEL
OBJECT_MODEL_ARRAY(axisDrivers)