Skip to content

Managing all PWM pins on TC1 #489

Answered by Rahix
pmnlla asked this question in Q&A
Jan 11, 2024 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

There is a fundamental difference between our PWM implementation and the one in the Arduino Servo library: While we use hardware PWM where the timer directly drives the output pin, the Servo library implements a software variant: A timer triggers an interrupt and the interrupt routine then toggles pins as needed. This is what allows them to control arbitrary pins as PWM signals (but limits the PWM frequency, which isn't a problem for Servo control).

You could implement this by hand using avr-hal, by manually setting up the timer and interrupt as needed. See https://github.com/Rahix/avr-hal/blob/main/examples/arduino-uno/src/bin/uno-millis.rs for some timer code.

However, in the long run, …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@pmnlla
Comment options

@pmnlla
Comment options

@pmnlla
Comment options

Answer selected by pmnlla
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants