cpu/samd21: pwm: allow to use channels > 3#13797
Merged
dylad merged 2 commits intoRIOT-OS:masterfrom Apr 8, 2020
Merged
Conversation
Channels 4…7 are on the CCB register.
GCLK_ID and APBCMASK entries are not always uniform. The previous hack would already break for TCC3. Just explosively write down the cases, there are only 5 at most.
dylad
approved these changes
Apr 8, 2020
Member
dylad
left a comment
There was a problem hiding this comment.
Tested work on an out of the tree board with 3 PWM channels. (2 of them were broken on master).
Changes look good so let's wait for Murdock.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Contribution description
Each TCC device has 8 capture-compare channels, but RIOT will crash when accessing any channel > 3.
This is because the upper for channels are on the
CCBset of registers.There was also a bit of a hack in place to get the TCC ID (and from that the GCLK_ID & APBCMASK) by masking out some bits from the register address of the hardware blocks.
But TCC devices are not always adjacent in memory - this already breaks for samd21 devices that have a
TCC3and is certainly broken for non-samd21 MCUs.Testing procedure
Run
tests/periph_pwmon a samd21 board with pwm configured (e.g.samr21-xpro)The
oscitest should blink the on-board LED when configured properly.Issues/PRs references
Needed for the PWM config of the serpente board #13654