Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

Commit

Permalink
DDA, dda_start(): don't pass mb_tail_dda as parameter.
Browse files Browse the repository at this point in the history
Instead, read the global variable directly.

The idea is that reading the global variable directly removes
the effort to build up a parameter stack, making things faster.

Actually, binary size increases by 4 bytes and the slowest step
takes 3 clock cycles longer. D'oh.

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19274 bytes      135%       63%       31%       15%
     Data:   2179 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 218 clock cycles.
  LED on time maximum: 398 clock cycles.
  LED on time average: 249.111 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 441 clock cycles.
  LED on time average: 272.222 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 398 clock cycles.
  LED on time average: 262.576 clock cycles.
  • Loading branch information
Traumflug committed Dec 6, 2016
1 parent d5eb8cd commit 480cc40
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions dda.c
Expand Up @@ -482,7 +482,6 @@ void dda_create(DDA *dda, const TARGET *target) {
}

/*! Start a prepared DDA
\param *dda pointer to entry in dda_queue to start
This function actually begins the move described by the passed DDA entry.
Expand All @@ -492,8 +491,8 @@ void dda_create(DDA *dda, const TARGET *target) {
Called both inside and outside of interrupts.
*/
void dda_start(DDA *dda) {
// called from interrupt context: keep it simple!
void dda_start() {
DDA *dda = mb_tail_dda;

if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
sersendf_P(PSTR("Start: X %lq Y %lq Z %lq F %lu\n"),
Expand Down
2 changes: 1 addition & 1 deletion dda.h
Expand Up @@ -187,7 +187,7 @@ void dda_new_startpoint(void);
void dda_create(DDA *dda, const TARGET *target);

// start a created DDA (called from timer interrupt)
void dda_start(DDA *dda);
void dda_start(void);

// DDA takes one step (called from timer interrupt)
void dda_step(DDA *dda);
Expand Down
4 changes: 2 additions & 2 deletions dda_queue.c
Expand Up @@ -71,7 +71,7 @@ void queue_step() {
if (mb_tail != mb_head) {
mb_tail = MB_NEXT(mb_tail);
mb_tail_dda = &(movebuffer[mb_tail]);
dda_start(mb_tail_dda);
dda_start();
}
else {
mb_tail_dda = NULL;
Expand Down Expand Up @@ -123,7 +123,7 @@ void enqueue_home(TARGET *t, uint8_t endstop_check, uint8_t endstop_stop_cond) {
timer_reset();
mb_tail = mb_head; // Valid ONLY if the queue was empty before!
mb_tail_dda = new_movebuffer; // Dito!
dda_start(mb_tail_dda);
dda_start();
// Compensate for the cli() in timer_set().
sei();
}
Expand Down

0 comments on commit 480cc40

Please sign in to comment.