From 82fc54a1ceb3473e7a79a02dbc65abc556cdf93b Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Tue, 5 Feb 2013 23:37:16 +0000 Subject: motor with timer working git-svn-id: https://svn.spreadspace.org/avr/trunk@120 aa12f405-d877-488e-9caf-2d797e2a1cc7 --- usb-i2c-sl018/stepper.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'usb-i2c-sl018/stepper.c') diff --git a/usb-i2c-sl018/stepper.c b/usb-i2c-sl018/stepper.c index 868fff0..4264a42 100644 --- a/usb-i2c-sl018/stepper.c +++ b/usb-i2c-sl018/stepper.c @@ -46,10 +46,18 @@ uint8_t step_table [] = #define STEPPER_OUTPUT_BITMASK (~(0xF << STEPPER_FIRST_BIT )) volatile uint16_t step_cnt = 0; -static uint16_t step_cnt_max = LENGTH_STEP_TABLE*20; +static uint16_t step_cnt_max = LENGTH_STEP_TABLE*200; stepper_direction_t step_direction = dir_open; -void handle_step(void) +inline void stop_stepper(void) +{ + // stop timer here + STEPPER_PORT &= ~(0xF << STEPPER_FIRST_BIT | 1< 2 ms @ 16 MHz + //OCR1A = 155; // (1+155)*256 = 40000 -> 2 ms @ 20 MHz + TCNT1 = 0; // reseting timer + TIMSK1 = 1<