Commit Graph

32 Commits

Author SHA1 Message Date
Markus Hitter 7528037d4e Save status register on each interrupt.
Costs 28 bytes binary size and two CPU cycles per interrupt,
at the advantage of getting rid of possible well hidden bugs.
2012-03-04 19:02:38 +01:00
Markus Hitter c126629ec8 Make the step timer fit for very short delays.
This isn't the magic patch which suddenly allows us to run at
arbitrary high step rates, but can deal with short bursts of
very short delays only. Typical for a 45 deg move when using
ACCELERATION_TEMPORAL.

The implementation simply extends the impossible small delay.
To keep overall timing promises regardless, the extra is stored
and compensated for when a longer delay request comes in.

Wrapped all this in #ifdef ACCELERATION_TEMPORAL, as this adds
about 300 bytes of binary size, so it likely slows down the
setTimer() code a bit and non-temporal algorithms are expected to
never request an unreasonable short delay.
2012-03-04 19:02:28 +01:00
Markus Hitter fd91ee7e8b dda.c: re-introduce ACCELERATION_TEMPORAL.
The implementation is slightly different this time, as it's not
using these famous bresenham algorithms. The intention is to
allow axis-independent movements, as it's required for
EMC-quality look-ahead.
2012-03-04 19:02:17 +01:00
Markus Hitter 69610a6dae timer.c: simplify clock counting a bit.
Nothing fancy, but it saves 8 bytes, so likely 8 cycles.
2011-11-21 09:56:12 +01:00
Markus Hitter 9c489911b6 timer.c: get rid of explicitely disabling the step timer.
This is no longer neccessary, as the step timer is not designed to
fire always exactly once.

Saves 54 bytes binary size.
2011-11-21 09:54:41 +01:00
Markus Hitter 53490bb318 Get rid of defered enabling of the step interrupt again.
This makes the code cleaner and the reduction of code
probably easily compensates for keeping global interrupts
enabled for a bit longer. Talked to macscifi about this.

Saves about 300 bytes of binary size.
2011-11-21 09:54:38 +01:00
Jens Ch. Restemeier cea2a656a5 Fix assumption that debug led is on SCK pin
Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
2011-06-10 22:58:25 +10:00
Jim McGee f555887eb5 Testing and setting the delay to a minimum value needs to occur only
if delay is not zero, otherwise the timer is not turned off when it
should be. Move the test and setting back inside the block that is only
executed if delay > 0.
2011-05-15 16:48:25 +10:00
Jim McGee 5dc0c80f0b Defer enabling of timer1_compa interrupt the end of the interrupt handler.
Specifically, disable interrupts just before returning and then enable
the timer interrupt if appropriate. This means that the timer interrupt
cannot actually fire until after the RETI, so the function cannot be
entered recursively.
2011-05-15 09:56:33 +10:00
Jim McGee 57b30b0ff1 Set a minimum delay instead of attempting to call the timer interrupt
service routine in the case that the requested timer interval is too
small.

Calling the interrupt service routine at this point is likely to
recursively clobber the stack.

Setting a lower bounds on the interrupt delay will limit the upper
speed of pulse generation, but it should not change the relative
pulse rates, and will not recurvisely clobber the stack.

Note that the lower limit of 17 has not been researched, it is
simply the value below which the old code attempted to call
the interrupt service routine directly.
2011-05-15 09:56:33 +10:00
Jim McGee 8241549276 Remove volatile from next_step_time as it can be easily managed using
memory barriers since it is only touched inside a single interrupt
handler or while interrupts are disabled in setTimer().

This saves about 90 bytes since it no longer needs to be reloaded multiple
times.
2011-05-15 09:56:33 +10:00
Jim McGee f22e691fee Convert the clock_flag variable into 3 separate varables.
This costs 2 bytes of ram, but saves 60 bytes of flash. Doing so
also eliminates the need to disable interrupts while clearing flags
in the ifclock macro.

Conflicts:

	clock.c
	timer.c
	timer.h
2011-05-15 09:56:32 +10:00
Michael Moon be81a13584 make sure timer is initialised properly
Reported-by: jv4779 <jv4779@gmail.com>
2011-04-30 11:00:11 +10:00
Michael Moon 0dc7d77885 Massive Doxygen documentation addition
'make doc' then point your browser at doc/html/

Needs plenty of cleanup and polishing, but the main bulk is here

even documents your configuration! ;)
2011-03-22 01:34:36 +11:00
Markus Hitter 851a91306a timer.c: don't reset next_step_time when doing a step.
Doing so adds most of the interrupt execution time to the
step time, see line 126 of the same file:

    if (next_step_time == 0) {
      // new move, take current time as start value
      step_start = TCNT1;
    }
2011-03-14 17:34:26 +01:00
Michael Moon d0601716e8 reorganise intercom to send packets from extruder main loop, also generalise protocol as discussed in forum 2011-03-05 13:38:12 +11:00
Markus Hitter 4ca9e470a5 Move timer macros from config.h.dist and derivates to timer.c.
This sould confuse users less and neither value is subject to change
per configuration. Reviewed also by Markus Amsler.
2011-02-23 12:37:15 +01:00
Michael Moon 3c5acd7ca7 disable interrupt if setTimer(0) is called 2011-02-11 11:53:27 +11:00
Michael Moon d91f30eda1 ensure step timer doesn't fire by itself after a period of inactivity 2011-02-10 19:57:16 +11:00
Markus Amsler 69f30f0691 timer: Use 2 comparator interrupts, one for the clock, the other for stepping.
The old implementation with an overflow interrupt for the clock and a comparator interrupt for stepping, had an unsolvable bug: If the comparator interrupt should happen very shortly after the overflow interrupt the comparator interrupt would miss. And with 2 comparators the implementation is more straightforward.
2011-02-10 19:53:58 +11:00
Markus Amsler d5033895b2 Fix timer for high speeds. 2011-02-08 21:57:58 +11:00
Michael Moon 00fc05a49b fix timer bug- if delay is smaller than TICK_TIME but counter has passed delay when timer is set, it will wait a whole TICK_TIME before firing instead of setting comparator to fire at correct time
check next_step_time instead of delay in comparison

Reported-by: Markus Amsler <markus.amsler@oribi.org>
2011-02-08 09:43:50 +11:00
Michael Moon 096d7dfdf3 Merge release-candidate-triffid branch 2011-01-07 23:09:13 +11:00
Michael Moon e3d0aa7b62 split delay functions into separate files 2010-10-11 10:12:35 +11:00
Markus Hitter 95939ecc22 Don't disable the stepper timer interrupt while stepping.
After lots of try and error the conclusion was, disabling this
interrupt makes the timer vulnerable to be messed up by
characters incoming over the serial line. So, now the
interrupt is enabled as a move starts and not disabled before
the move, and all subsequent moves are done.
2010-10-04 16:05:01 +02:00
Markus Hitter f98772ff25 timer.c: remove a few obsolete #includes. 2010-10-04 16:04:12 +02:00
Michael Moon e78381c56d Move configuration to config.h.dist 2010-09-27 09:20:07 +10:00
Markus Hitter 64683e6b6a Remove timer reset, as this doesn't play well. See
http://github.com/triffid/FiveD_on_Arduino/issues#issue/2/comment/428863 .
2010-09-25 12:08:23 +02:00
Michael Moon c1dbd869f5 minor fixes: comments, indenting, etc 2010-09-18 08:08:31 +10:00
Michael Moon 92eb4c97ca reset timer properly for more accurate timing 2010-09-16 21:42:24 +10:00
Michael Moon 48cf0e05d7 some code cleanup, added M114, wrapped M25[0..5] in ifdef DEBUG wrapper 2010-09-12 12:54:58 +10:00
Michael Moon 595b66a341 setting up new branch 2 2010-08-10 14:26:24 +10:00