fix(PeriphDrivers): Don't cache TMR clock frequency if locked #1188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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