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

fix(PeriphDrivers): Don't cache TMR clock frequency if locked #1188

Conversation

perkinsmg
Copy link
Contributor

@perkinsmg perkinsmg commented Sep 23, 2024

Description

We have a locking mechanism so that if we've locked the TMR clock, then calling MXC_TMR_Init() function doesn't reset them.

However, the lock check is implemented in MXC_TMR_RevB_SetClockSource, which is called by MXC_TMR_SetClockSource. However, MXC_TMR_SetClockSource also calls MXC_TMR_RevB_SetClockSourceFreq, which has no lock check.

The result is that if MXC_TMR_Init is called with a clock source of, say, ERFO, then we cache the new frequency, 32MHz, but then don't reconfigure the MMRs to actually run using ERFO. So the TMR driver operates believing it is running at 32MHz, but actually running at something else. This means that things like the Stop Watch timer report the wrong wall time.

Checklist Before Requesting Review

  • PR Title follows correct guidelines.
  • Description of changes and all other relevant information.
  • (Optional) Link any related GitHub issues using a keyword
  • (Optional) Provide info on any relevant functional testing/validation. For API changes or significant features, this is not optional.

We have a locking mechanism so that if we've locked the TMR clock, then calling MXC_TMR_Init() function doesn't reset them.

However, the lock check is implemented in MXC_TMR_RevB_SetClockSource, which is called by MXC_TMR_SetClockSource. However, MXC_TMR_SetClockSource also calls MXC_TMR_RevB_SetClockSourceFreq, which has no lock check.

The result is that if MXC_TMR_Init is called with a clock source of, say, ERFO, then we cache the new frequency, 32MHz, but then don't reconfigure the MMRs to actually run using ERFO. So the TMR driver operates believing it is running at 32MHz, but actually running at something else. This means that things like the Stop Watch timer report the wrong wall time.

Signed-off-by: Michael Perkins <michael.perkins@analog.com>
@sihyung-maxim sihyung-maxim merged commit 822491e into analogdevicesinc:main Sep 24, 2024
12 checks passed
sihyung-maxim pushed a commit to analogdevicesinc/hal_adi that referenced this pull request Sep 24, 2024
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.

2 participants