Commit Graph

6 Commits

Author SHA1 Message Date
Markus Hitter 7afbc70d58 Step timer: reset timer after pauses instead of doing a guess.
We know already wether we start from a pause or not, so let's
take advantage of this knowledge instead of checking for
plausibility of a timer delay at interrupt time.

Costs just 8 bytes binary size:

    SIZES          ARM...     lpc1114
    FLASH  :  7764 bytes          24%
    RAM    :   960 bytes          24%
    EEPROM :     0 bytes           0%

Due to the less code at interrupt time, maximum step rate was
raised from 127.9 kHz to 130.6 kHz.
2015-08-12 14:26:37 +02:00
Markus Hitter f32693bf4e ARM: extend the SysTick handler to also call dda_clock().
As dda_clock() is potantially too slow for high step rates, we
call it with a secondary interrupt with slightly slower priority.
This makes sure the slow part is ignored on high system load,
still reasonably synchonized with the clock tick.

Test: steppers should move and accelerate now.

Current binary size:

    SIZES          ARM...     lpc1114
    FLASH  :  7756 bytes          24%
    RAM    :   960 bytes          24%
    EEPROM :     0 bytes           0%
2015-08-12 14:26:37 +02:00
Markus Hitter a171a0c57f ARM: implement the stepper interrupt.
Works nicely, much less code than on AVR, because we have 32-bit
hardware timers.

Test: steppers should move. Only slowly, because dda_clock() isn't
called, yet, so no acceleration.

Pulse time on the Debug LED is 5.21 us or 250 clock ticks.
2015-08-12 14:26:37 +02:00
Markus Hitter c118d00383 ARM: get clock.c in.
No code changes neccessary.

This code in ifclock(clock_flag_1s) in clock.c should give a nice,
accurate clock:

    static uint8_t minutes = 0, seconds = 0;

    seconds++;
    if ( ! (seconds % 60)) {
      seconds = 0;
      minutes++;
    }
    sersendf_P(PSTR("%su:"), minutes);
    if (seconds < 10)
      serial_writechar('0');
    sersendf_P(PSTR("%su\n"), seconds);

Current sizes are:

    SIZES          ARM...     lpc1114
    FLASH  :  4440 bytes          14%
    RAM    :   200 bytes           5%
    EEPROM :     0 bytes           0%
2015-08-12 14:26:36 +02:00
Markus Hitter 137a638658 ARM: get timer.c in, so far only with the system clock.
This test code in SysTickHanlder() should give you a rather
accurate clock with only a few seconds deviation per hour:

  #include "serial.h"
  #include "sersendf.h"
  void SysTick_Handler(void) {
    static uint32_t count = 0;
    static uint8_t minutes = 0, seconds = 0;

    count++;

    if ( ! (count % 500)) {   // A full second.
      seconds++;
      if ( ! (seconds % 60)) {
        seconds = 0;
        minutes++;
      }
      sersendf_P(PSTR("%su:"), minutes);
      if (seconds < 10)
        serial_writechar('0');
      sersendf_P(PSTR("%su\n"), seconds);
    }
  [...]
2015-08-12 14:26:36 +02:00
Markus Hitter feeb411eec ARM: split timer.c into platform specific files.
AVR and simulator are kept together, because the simulator
apparently simulates much of the AVR timer infrastructure.

ARM variant is empty, so far.
2015-08-12 14:26:36 +02:00