Better handling of DELAY_NS and DELAY_US (#10716)
Co-Authored-By: ejtagle <ejtagle@hotmail.com>
This commit is contained in:
@ -41,15 +41,18 @@
|
||||
* along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith
|
||||
and Philipp Tiefenbacher. */
|
||||
/**
|
||||
* Timer calculations informed by the 'RepRap cartesian firmware' by Zack Smith
|
||||
* and Philipp Tiefenbacher.
|
||||
*/
|
||||
|
||||
/* Jerk controlled movements planner added by Eduardo José Tagle in April
|
||||
2018, Equations based on Synthethos TinyG2 sources, but the fixed-point
|
||||
implementation is a complete new one, as we are running the ISR with a
|
||||
variable period.
|
||||
Also implemented the Bézier velocity curve evaluation in ARM assembler,
|
||||
to avoid impacting ISR speed. */
|
||||
/**
|
||||
* Jerk controlled movements planner added Apr 2018 by Eduardo José Tagle.
|
||||
* Equations based on Synthethos TinyG2 sources, but the fixed-point
|
||||
* implementation is new, as we are running the ISR with a variable period.
|
||||
* Also implemented the Bézier velocity curve evaluation in ARM assembler,
|
||||
* to avoid impacting ISR speed.
|
||||
*/
|
||||
|
||||
#include "stepper.h"
|
||||
|
||||
@ -67,6 +70,7 @@
|
||||
#include "../gcode/queue.h"
|
||||
#include "../sd/cardreader.h"
|
||||
#include "../Marlin.h"
|
||||
#include "../HAL/Delay.h"
|
||||
|
||||
#if MB(ALLIGATOR)
|
||||
#include "../feature/dac/dac_dac084s085.h"
|
||||
@ -1471,7 +1475,7 @@ void Stepper::isr() {
|
||||
while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
||||
pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM);
|
||||
#elif EXTRA_CYCLES_XYZE > 0
|
||||
DELAY_NOPS(EXTRA_CYCLES_XYZE);
|
||||
DELAY_NS(EXTRA_CYCLES_XYZE * NANOSECONDS_PER_CYCLE);
|
||||
#endif
|
||||
|
||||
#if HAS_X_STEP
|
||||
@ -1506,7 +1510,7 @@ void Stepper::isr() {
|
||||
#if EXTRA_CYCLES_XYZE > 20
|
||||
if (i) while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
||||
#elif EXTRA_CYCLES_XYZE > 0
|
||||
if (i) DELAY_NOPS(EXTRA_CYCLES_XYZE);
|
||||
if (i) DELAY_NS(EXTRA_CYCLES_XYZE * NANOSECONDS_PER_CYCLE);
|
||||
#endif
|
||||
|
||||
} // steps_loop
|
||||
@ -1739,7 +1743,7 @@ void Stepper::isr() {
|
||||
while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
||||
pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM);
|
||||
#elif EXTRA_CYCLES_E > 0
|
||||
DELAY_NOPS(EXTRA_CYCLES_E);
|
||||
DELAY_NS(EXTRA_CYCLES_E * NANOSECONDS_PER_CYCLE);
|
||||
#endif
|
||||
|
||||
switch (LA_active_extruder) {
|
||||
@ -1762,7 +1766,7 @@ void Stepper::isr() {
|
||||
#if EXTRA_CYCLES_E > 20
|
||||
if (e_steps) while (EXTRA_CYCLES_E > (hal_timer_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
|
||||
#elif EXTRA_CYCLES_E > 0
|
||||
if (e_steps) DELAY_NOPS(EXTRA_CYCLES_E);
|
||||
if (e_steps) DELAY_NS(EXTRA_CYCLES_E * NANOSECONDS_PER_CYCLE);
|
||||
#endif
|
||||
|
||||
} // e_steps
|
||||
@ -2146,13 +2150,13 @@ void Stepper::report_positions() {
|
||||
#else
|
||||
#define _SAVE_START NOOP
|
||||
#if EXTRA_CYCLES_BABYSTEP > 0
|
||||
#define _PULSE_WAIT DELAY_NOPS(EXTRA_CYCLES_BABYSTEP)
|
||||
#define _PULSE_WAIT DELAY_NS(EXTRA_CYCLES_BABYSTEP * NANOSECONDS_PER_CYCLE)
|
||||
#elif STEP_PULSE_CYCLES > 0
|
||||
#define _PULSE_WAIT NOOP
|
||||
#elif ENABLED(DELTA)
|
||||
#define _PULSE_WAIT delayMicroseconds(2);
|
||||
#define _PULSE_WAIT DELAY_US(2);
|
||||
#else
|
||||
#define _PULSE_WAIT delayMicroseconds(4);
|
||||
#define _PULSE_WAIT DELAY_US(4);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "../lcd/ultralcd.h"
|
||||
#include "planner.h"
|
||||
#include "../core/language.h"
|
||||
#include "../HAL/Delay.h"
|
||||
|
||||
#if ENABLED(HEATER_0_USES_MAX6675)
|
||||
#include "../libs/private_spi.h"
|
||||
@ -681,14 +682,14 @@ float Temperature::get_pid_output(const int8_t e) {
|
||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||
cTerm[HOTEND_INDEX] = 0;
|
||||
if (_HOTEND_TEST) {
|
||||
long e_position = stepper.position(E_AXIS);
|
||||
const long e_position = stepper.position(E_AXIS);
|
||||
if (e_position > last_e_position) {
|
||||
lpq[lpq_ptr] = e_position - last_e_position;
|
||||
last_e_position = e_position;
|
||||
}
|
||||
else {
|
||||
else
|
||||
lpq[lpq_ptr] = 0;
|
||||
}
|
||||
|
||||
if (++lpq_ptr >= lpq_len) lpq_ptr = 0;
|
||||
cTerm[HOTEND_INDEX] = (lpq[lpq_ptr] * planner.steps_to_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX);
|
||||
pid_output += cTerm[HOTEND_INDEX];
|
||||
@ -1629,7 +1630,7 @@ void Temperature::disable_all_heaters() {
|
||||
|
||||
WRITE(MAX6675_SS, 0); // enable TT_MAX6675
|
||||
|
||||
DELAY_100NS; // Ensure 100ns delay
|
||||
DELAY_NS(100); // Ensure 100ns delay
|
||||
|
||||
// Read a big-endian temperature value
|
||||
max6675_temp = 0;
|
||||
|
Reference in New Issue
Block a user