Implemented 31kHz PWM output

This commit is contained in:
Aditya Pulipaka
2025-11-22 14:44:25 -06:00
parent 5c9a67e1d3
commit 28e33651a3
12 changed files with 51 additions and 14 deletions

11
lib/FastPWM.cpp Normal file
View File

@@ -0,0 +1,11 @@
#include "FastPWM.hpp"
void setupFastPWM() {
// Timer 1 (Pins 9 & 10) -> 31.25 kHz
TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(WGM10);
TCCR1B = _BV(CS10);
// Timer 2 (Pins 3 & 11) -> 31.25 kHz
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM20);
TCCR2B = _BV(CS20);
}