Fixed Race-Condtion problem with arming of done_flag

This commit is contained in:
AlexanderHD27
2024-09-27 23:21:04 +02:00
parent 986927d740
commit f3490212bf
5 changed files with 65 additions and 25 deletions

View File

@@ -23,14 +23,14 @@ counter:
l1:
PULL NOBLOCK
MOV Y, OSR
MOV X, OSR
JMP !Y l1_end
IRQ WAIT 2 REL
IRQ WAIT 2 REL
SET PINS, 1
IRQ WAIT 2 REL
SET PINS, 0
MOV X, OSR
JMP X-- l1
l1_end:

View File

@@ -167,6 +167,8 @@ void TMC2209_step_dual::set_conf1(uint frequency, bool dir) {
void TMC2209_step_dual::pulse0(uint n) {
this->remaining_step_count0 = n;
this->done_flag0_arm = true;
this->done_flag0 = false;
pio_sm_put_blocking(
this->pio_core, this->sm_num_counter0, n
);
@@ -175,12 +177,15 @@ void TMC2209_step_dual::pulse0(uint n) {
void TMC2209_step_dual::pulse1(uint n) {
this->remaining_step_count1 = n;
this->done_flag1_arm = true;
this->done_flag1 = false;
pio_sm_put_blocking(
this->pio_core, this->sm_num_counter1, n
);
};
void TMC2209_step_dual::pulse0_int(int n) {
this->remaining_step_count0 = n;
this->done_flag0_arm = true;
if(n < 0) {
n = abs(n);
@@ -193,6 +198,7 @@ void TMC2209_step_dual::pulse0_int(int n) {
};
void TMC2209_step_dual::pulse1_int(int n) {
this->remaining_step_count1 = n;
this->done_flag1_arm = true;
if(n < 0) {
n = abs(n);
@@ -212,6 +218,7 @@ void TMC2209_step_dual::irq_handler0() {
} else {
done_flag0 = false;
}
pio_interrupt_clear(this->pio_core, 2);
}