-
Notifications
You must be signed in to change notification settings - Fork 223
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
New Timers #151
Comments
|
Is there an API that translates from the data sheet to the register writes? Right now I have code that does
It would probably be more readable if it looked like
or maybe
Although I am certain that the example code I provided drastically oversimplifies the options. I assume this code will look a little different for each AVR implementation unless they all have the same register layout. |
A quick review of the datasheets for the atmega328p (https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf) and the atmega2560(https://ww1.microchip.com/downloads/en/devicedoc/atmel-2549-8-bit-avr-microcontroller-atmega640-1280-1281-2560-2561_datasheet.pdf) shows: 328p: 2560: When comparing the registers on the 328p and the 2560 one thing that jumps out is that the 2560 has A, B, and C (section 17.11.17-28) comparators on its 16-bit timers, while the 328p only has A and B (section 15.11.5&6). I was hoping that the two models could be unified by some traits, but it will not be as clean as I initially hoped. I'm also unsure how this timer architecture generalizes across the other AVR implementations. |
I have created a couple of timer experiments that I hope to turn into examples for the avr-hal project: https://github.com/mutantbob/avr-timer/blob/master/led-pwm/src/megalovania.rs uses PWM and a buzzer to play a chiptune https://github.com/mutantbob/avr-timer/blob/master/led-pwm/src/led-pwm.rs uses PWM with a duty cycle to control LED brightness. If these apps are suitable use cases for the arduino-uno examples, let me know what changes are needed to bring them to their final form. It is also possible that they can serve as uses cases to drive a more friendly timer API. |
This issue serves to track efforts on re-designing the timer API as part of #130. As a first step, I think we should gather a list of "use-cases" that should be supported:
millis()
Cc: @koutoftimer
The text was updated successfully, but these errors were encountered: