Skip to content

Commit 4b90dea

Browse files
committed
avr: set direction pin before first step
1 parent 5a9583d commit 4b90dea

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

examples/StepperDemo/StepperDemo.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "FastAccelStepper.h"
22
#include "test_seq.h"
33

4-
#define VERSION "post-cd46b49"
4+
#define VERSION "post-5a9583d"
55

66
struct stepper_config_s {
77
uint8_t step;

src/StepperISR_avr.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ void StepperQueue::init(uint8_t queue_num, uint8_t step_pin) {
137137
if (rp == fas_queue_##CHANNEL.next_write_idx) { \
138138
/* queue is empty => set to disconnect */ \
139139
Stepper_Disconnect(T, CHANNEL); \
140-
/* disable compare interrupt */ \
141-
DisableCompareInterrupt(T, CHANNEL); \
142140
/* force compare to ensure disconnect */ \
143141
ForceCompare(T, CHANNEL); \
142+
/* disable compare interrupt */ \
143+
DisableCompareInterrupt(T, CHANNEL); \
144144
fas_queue_##CHANNEL.isRunning = false; \
145145
fas_queue_##CHANNEL.queue_end.ticks = TICKS_FOR_STOPPED_MOTOR; \
146146
return; \
@@ -218,6 +218,10 @@ AVR_CYCLIC_ISR_GEN(FAS_TIMER_MODULE)
218218
} else { \
219219
Stepper_Zero(T, CHANNEL); \
220220
} \
221+
if (e->toggle_dir) { \
222+
uint8_t dirPin = fas_queue_##CHANNEL.dirPin; \
223+
digitalWrite(dirPin, digitalRead(dirPin) == HIGH ? LOW : HIGH); \
224+
} \
221225
/* clear interrupt flag */ \
222226
ClearInterruptFlag(T, CHANNEL); \
223227
/* enable compare interrupt */ \

0 commit comments

Comments
 (0)