SubGhz: fix sample durations when using external CC1101 #4205
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.
What's new
The external CC1101 plugin sets up TIM17 to tick once every 2us, but does so without triggering an update with
LL_TIM_GenerateEvent_UPDATE(). This means that the prescaler isn't actually applied until the counter register overflows. Until then, since the default prescaler value is 0, bits are reported as being 128x the duration that they actually are.If the GDO0 pin of the external CC1101 toggles fast enough (at least once every 0xFFFF/64MHz = ~1ms minus ISR overhead),
subghz_device_cc1101_ext_capture_ISR()will keep resetting the counter before it has a chance to overflow, preventing the correct prescaler from being applied for an arbitrary amount of time.This PR uses
LL_TIM_Init()to initialize the timer instead, which callsLL_TIM_GenerateEvent_UPDATE()to immediately apply the config.Verification
To see the issue with the old code:
You can repeat the same steps with the new code, and verify that the issue is no longer present.
Checklist (For Reviewer)