-
Notifications
You must be signed in to change notification settings - Fork 70
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
No ctc
function for atmega328p
's WGM1_W
#96
Comments
This is usually an inconsistency in the vendor-provided ATDF files. We have infrastructure here in Whenever you encounter such inconsistencies, please feel free to send a PR here with a fix :) |
Hmm, I'm trying to wrap my head around this ATDF stuff. If I understand it correctly, the "vendor" only defines the avr-device/vendor/atmega328p.atdf Line 847 in 4adeecd
and avr-device/vendor/atmega328p.atdf Line 841 in 4adeecd
Then, the patch files define an enum on them (or seemingly only on avr-device/patch/timer/dev/8bit.yaml Lines 17 to 22 in 4adeecd
And from that enum the However, this data sheet of the According to the data sheet, it gets even more complex with the Thus, it seems that it would be more appropriate to have a |
Ah, you got it and now I also remember: We didn't add enum-values for this timer precisely because of the split bit-field. There is no way to represent this in SVD so code unfortunately has to manually set the bit-values for these timers... |
Actually, this can be seen, for example, in the old PWM implementation. There, a setup function had to be defined manually for each timer. Compare with I don't think there are really any other options than doing it this way :/ Maybe enough timers are similar enough to create some macro-magic to reduce code-duplication but then this would of course make it much harder to understand... So I'm not sure if that would be worth it. |
I guess one could also argue for the removal of the Setting COM?? to 0b01 doesn't always mean "match_toggle" for example, since it depends on what mode the timer is in (as pointed out by the patch itself). That being said -- it sure is convenient to have human-readable settings for some of this stuff, but it seems to me like the abstractions necessary to cover all the different combinations of modes and settings in a user-friendly way is something that maybe belongs in avr-hal rather than in avr-device(?). These are just speculations from my part, as I haven't really dug into avr-device that much, but it did cause a bit of confusion on my part whilst playing around with different PWM generation modes on the atmega328p and attiny85, and in the end I opted for the |
It's a difficult decision to make... I completely agree that a proper abstraction on top is needed and it should go into However, when looking at the original PWM abstraction, we did leverage the enumerated value names for some of the timers, so I think there is value in keeping them... I am not sure to what degree though, because as you mentioned, sometimes the existing ones are actually wrong, too... |
Ok, I added clearing the top bit for 8-bit timers: and configured 16-bit timers by setting the raw bits: Thus, I no longer consider this issue a blocker for Rahix/avr-hal#257 |
I'm a bit puzzled, why is there no
ctc
function onatmega328p::tc1::tccr1a::WGM1_W
, as it is the case forWGM0_W
andWGM2_W
?This inconsistency came up while I was working on Rahix/avr-hal#257. Not having this or a comparable function makes it hard to use timers in a generic way.
The text was updated successfully, but these errors were encountered: