Closed miam-miam closed 2 years ago
You're right, pins d5
and d6
on the uno (which are PD5
and PD6
of the ATmega328P) use TC0
. There is some code on the old
branch which had support for PWM ouput. For reference, here it is:
This was tested, so it should not be too hard to derive what you need from it. Looking at your code, a difference I see is that you set the wgm
differently. You'll also probably want to enable PWM output on both pins (in this case ocr0a
/com0a
is for d6
and ocr0b
/com0b
is for d5
).
let tc0 = dp.TC0;
tc0.tccr0a
.write(|w| w.wgm0().pwm_fast().com0a().match_clear().com0b().match_clear());
tc0.tccr0b
.write(|w| w.cs0().prescale_64());
I cannot run any tests of this right now, unfortunately. Let me know if it does not work.
Works perfectly thanks!
Hi I am trying to get the PWM working on an Arduino Uno on pins 5 and 6 to emulate the
analogWrite()
function but it doesn't work at all. I looked at #194 but the pins 5 and 6 of the Arduino Uno use a different frequency and timer. Would it be possible for someone to help me?