diff --git a/app/by_stepper.c b/app/by_stepper.c index 6e71b91..f7c3ec9 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 @@ -138,7 +138,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) { @@ -151,10 +151,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(); }