diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-01-22 01:06:36 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-01-22 01:06:36 +0300 |
commit | cdb1728cef3b1a1e618fe81be3768a2d3d748795 (patch) | |
tree | 7fc74c23707f5fad628486978c6e5543c080b01c /src | |
parent | 6ac8f4b9209491d8444429c6a56cbc4e992c361a (diff) |
Fixes for MB6XD
Diffstat (limited to 'src')
-rw-r--r-- | src/Config/Pins_Duet3_MB6HC.h | 4 | ||||
-rw-r--r-- | src/Config/Pins_Duet3_MB6XD.h | 2 | ||||
-rw-r--r-- | src/Hardware/SAME70/Devices.cpp | 10 | ||||
-rw-r--r-- | src/Movement/DDA.cpp | 7 | ||||
-rw-r--r-- | src/Platform/Platform.cpp | 8 |
5 files changed, 26 insertions, 5 deletions
diff --git a/src/Config/Pins_Duet3_MB6HC.h b/src/Config/Pins_Duet3_MB6HC.h index 7ca8a7ba..8b4c2b63 100644 --- a/src/Config/Pins_Duet3_MB6HC.h +++ b/src/Config/Pins_Duet3_MB6HC.h @@ -152,9 +152,9 @@ constexpr bool DiagOnPolarity = true; // SD cards constexpr size_t NumSdCards = 2; // we now allow one SPI-connected SD card to be configured at boot time -constexpr Pin SdCardDetectPins[NumSdCards] = { PortAPin(29), NoPin }; +constexpr Pin SdCardDetectPins[NumSdCards] = { PortAPin(29), NoPin }; // the CD pin for the second SD card is allocated using M950 constexpr Pin SdWriteProtectPins[NumSdCards] = { NoPin, NoPin }; -constexpr Pin SdSpiCSPins[NumSdCards] = { NoPin, NoPin }; +constexpr Pin SdSpiCSPins[1] = { NoPin }; // this one is allocated using M950 constexpr uint32_t ExpectedSdCardSpeed = 25000000; constexpr IRQn SdhcIRQn = HSMCI_IRQn; diff --git a/src/Config/Pins_Duet3_MB6XD.h b/src/Config/Pins_Duet3_MB6XD.h index b15c82a1..5e06f4f7 100644 --- a/src/Config/Pins_Duet3_MB6XD.h +++ b/src/Config/Pins_Duet3_MB6XD.h @@ -136,7 +136,7 @@ constexpr bool DiagOnPolarity = false; constexpr size_t NumSdCards = 2; constexpr Pin SdCardDetectPins[NumSdCards] = { PortAPin(29), PortDPin(18) }; constexpr Pin SdWriteProtectPins[NumSdCards] = { NoPin, NoPin }; -constexpr Pin SdSpiCSPins[NumSdCards] = { NoPin, PortDPin(19) }; +constexpr Pin SdSpiCSPins[1] = { PortDPin(19) }; constexpr uint32_t ExpectedSdCardSpeed = 25000000; constexpr IRQn SdhcIRQn = HSMCI_IRQn; diff --git a/src/Hardware/SAME70/Devices.cpp b/src/Hardware/SAME70/Devices.cpp index 008ac348..19f14226 100644 --- a/src/Hardware/SAME70/Devices.cpp +++ b/src/Hardware/SAME70/Devices.cpp @@ -78,8 +78,18 @@ void DeviceInit() noexcept SdhcInit(); EthernetInit(); +#if defined(DUET3_MB6HC) // Set up PB4..PB5 as normal I/O, not JTAG matrix_set_system_io(CCFG_SYSIO_SYSIO4 | CCFG_SYSIO_SYSIO5); +#elif defined(DUET3_MB6XD) +# ifdef DEBUG + // Set up PB4..PB5 as normal I/O, not JTAG. Leave PB6/7 pins as SWD. STATUS and ACT LEDs will not work. + matrix_set_system_io(CCFG_SYSIO_SYSIO4 | CCFG_SYSIO_SYSIO5); +# else + // Set up PB4..PB7 as normal I/O, not JTAG or SWD + matrix_set_system_io(CCFG_SYSIO_SYSIO4 | CCFG_SYSIO_SYSIO5 | CCFG_SYSIO_SYSIO6 | CCFG_SYSIO_SYSIO7); +# endif +#endif } void StopAnalogTask() noexcept diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp index e728f14a..74c4a05f 100644 --- a/src/Movement/DDA.cpp +++ b/src/Movement/DDA.cpp @@ -2009,6 +2009,7 @@ void DDA::StepDrivers(Platform& p, uint32_t now) noexcept } driversStepping &= p.GetSteppingEnabledDrivers(); + #ifdef DUET3_MB6XD if (driversStepping != 0) { @@ -2026,6 +2027,12 @@ void DDA::StepDrivers(Platform& p, uint32_t now) noexcept // Trigger the TC so that it generates a step pulse STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_CCR = TC_CCR_SWTRG; lastStepHighTime = StepTimer::GetTimerTicks(); + + // Calculate the next step times + for (DriveMovement *dm2 = activeDMs; dm2 != dm; dm2 = dm2->nextDM) + { + (void)dm2->CalcNextStepTime(*this); // calculate next step times + } } #else # if SUPPORT_SLOW_DRIVERS // if supporting slow drivers diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp index 0ae91ba1..4856c970 100644 --- a/src/Platform/Platform.cpp +++ b/src/Platform/Platform.cpp @@ -685,13 +685,16 @@ void Platform::Init() noexcept // 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 @@ -2809,19 +2812,20 @@ void Platform::UpdateDriverTimings() // 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; - constexpr float MicrosecondsPerStepGateClock = 1.0e6/(float)StepGateTcClockFrequency; 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; // Convert the quantised step pulse width back to microseconds - const float actualStepPulseMicroseconds = fclocks * MicrosecondsPerStepGateClock; + const float actualStepPulseMicroseconds = fclocks/StepGateClocksPerMicrosecond; // Now convert the other values from microseconds to step clocks stepPulseMinimumPeriodClocks = MicrosecondsToStepClocks(worstTimings[1] + actualStepPulseMicroseconds); directionSetupClocks = MicrosecondsToStepClocks(worstTimings[2]); directionHoldClocksFromLeadingEdge = MicrosecondsToStepClocks(worstTimings[3] + actualStepPulseMicroseconds); +//DEBUG +// debugPrintf("Clocks: %" PRIu32 " %" PRIu32 " %" PRIu32 "\n", stepPulseMinimumPeriodClocks, directionSetupClocks, directionHoldClocksFromLeadingEdge); } #endif |