Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free running timer #253

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

Free running timer #253

wants to merge 13 commits into from

Conversation

secworks
Copy link
Contributor

@secworks secworks commented Aug 15, 2024

Description

This PR implements a change to the existing timer to add a free running mode. This is currently an initial version. The testbenches has not been updated with tests of the new mode. But it builds and allow us to measure the amount of resources the changes cause.

Note that this PR breaks the behavior of the timer. Previously both the timer and the prescaler would count down from a set value. The PR changes this so that now the timer and prescaler starts at zero and counts up to the set values. Applications that look at the timer current_value will probably be confused. Applications that just sets the timer and wait for it to complete (stop running) will not be affected.

Fixes #252

Type of change

Please tick any that are relevant to this PR and remove any that aren't.

  • Bugfix (non breaking change which resolve an issue)
  • Feature (non breaking change which adds functionality)
  • Breaking Change (a change which would cause existing functionality to not work as expected)
  • Documentation (a change to documentation)

Submission checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my changes
  • I have tested and verified my changes on target
  • My changes are well written and CI is passing
  • I have squashed my work to relevant commits and rebased on main for linear history
  • I have added a "Co-authored-by: x" if several people contributed, either pair programming or by squashing commits from different authors.
  • I have updated the documentation where relevant (readme, dev.tillitis.se etc.)
  • QEMU is updated to reflect changes

       Add initial version of changes needed to allow the timer to
       optionally be free running.

       This commit changes how the prescaler and timer counts.
       Instead of down from a set value, they count from zero and up
       to a set value.

Signed-off-by: Joachim Strömbergson <[email protected]>
       Add support in the Timer API to enable the free runing mode.

Signed-off-by: Joachim Strömbergson <[email protected]>
@secworks secworks self-assigned this Aug 15, 2024
       Fix so that the timer counts the correct number of cycles
       (again).

       Make testbench self-testing.

Signed-off-by: Joachim Strömbergson <[email protected]>
       Change names of states and remove redundant state.
       Fix comments and printout to clarify.

Signed-off-by: Joachim Strömbergson <[email protected]>
Signed-off-by: Joachim Strömbergson <[email protected]>
       Reset the free_running_reg to reset
       Make test1 self checking.

Signed-off-by: Joachim Strömbergson <[email protected]>
Signed-off-by: Joachim Strömbergson <[email protected]>
       Added note that prescaler and timer shoild be set to nonzero
       values. Added note that prescaler and timer can't be changed
       when the timer is running.

       Changed reset values for timer and prescalet to one.

Signed-off-by: Joachim Strömbergson <[email protected]>
Signed-off-by: Joachim Strömbergson <[email protected]>
       Add testcase that verifies that using timer with prescaler
       works in free running mode.

Signed-off-by: Joachim Strömbergson <[email protected]>
       Change timer from counting to a specified value and stopping or
       free running, to always be free running. But now the timer sets
       a reached flag when the target number of ticks has been
       reached.

Signed-off-by: Joachim Strömbergson <[email protected]>
@mchack-work
Copy link
Member

Needs careful thought since this is a breaking change. What are apps supposed to do if they want to support both existing TKeys with the old timer and this timer? Implement both and somehow test what TKey they are running on?

Old apps with no such check will be very confused, of course.

Might be worth it to at least do some experiments on new external code we want to use if we can somehow mimic the behaviour of an increasing timer with software wrapping functions of the old timer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a free running timer, or a free running mode to the existing timer.
2 participants