From 07b967e5e2638802844a839dc271513310fbd5cf Mon Sep 17 00:00:00 2001 From: bmy <2583236812@qq.com> Date: Wed, 1 May 2024 17:35:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E8=BF=90=E5=8A=A8?= =?UTF-8?q?=E6=96=B9=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/by_stepper.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/by_stepper.c b/app/by_stepper.c index abb2150..bfa381a 100644 --- a/app/by_stepper.c +++ b/app/by_stepper.c @@ -116,7 +116,7 @@ void by_stepper_init(void) DWT_Delay(40U * (uint16_t)by_stepper.speed); } - by_stepper_set_speed(STEPPER_SPEED_DIV1); + by_stepper_set_speed(STEPPER_SPEED_DIV4); while (gpio_input_data_bit_read(GPIOB, GPIO_PINS_10) == SET) { gpio_bits_write(GPIOA, GPIO_PINS_8, by_stepper.dir ? TRUE : FALSE); // DIR @@ -135,7 +135,7 @@ void by_stepper_init(void) void by_stepper_loop(void) { int16_t temp = (int16_t)tmr_counter_value_get(TMR3); - position += (int64_t)temp; + position -= (int64_t)temp; tmr_counter_value_set(TMR3, 0); if (running_flag) { @@ -148,10 +148,10 @@ void by_stepper_loop(void) } else // 正常模式 { if (position_offset > 0) { - by_stepper_set_dir(0); + by_stepper_set_dir(1); by_stepper_run(); } else if (position_offset < 0) { - by_stepper_set_dir(1); + by_stepper_set_dir(0); by_stepper_run(); } @@ -165,7 +165,7 @@ void by_stepper_loop(void) } } else { - by_stepper_stop(0); + by_stepper_stop(1); } // if (position_offset) {