Skip to content

Util Timer enhancements #1444

@gfwilliams

Description

@gfwilliams
  • Currently we use a 64 bit time in the util times, which really slows things down as we're doing 64 bit maths inside the IRQ. We could move to 32 bits, perhaps switching to a 'time until scheduled' method rather than storing the raw system time.

  • We also use a queue which is shuffled around to reschedule, requiring a reasonably big copy each time. We could keep this constant and just have an array of indexes that we reordered. Another benefit of this would be that timers had unique IDs, so could be easily checked in the code.

  • Some things (like waveform and stepper) continually poll to see if the waveform is active or not. The waveform could actually just post to the event queue (using the new timer IDs) to avoid this polling.

  • When doing ADC reads, we wait in the IRQ for the read to complete. The HAL could be modified to allow an ADC read with callback function + user data, which would make waveform to take up a lot less time.

  • Currently timers are set using a global time. It means that stuff like digitalPulse has to use getTime()+pulseLength internally which makes the accuracy dependent on the RTC. We could just avoid using the RTC completely - timing would potentially be a little less accurate (because of the time taken to reschedule the event not being counted via the timer) but then most Util Timer tasks are reasonably short-lived anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions