Sto cercando di manipolare il timer5 della mega2560 al fine di impostare phase and frequency pwm sui pin 44 e 45 , ma io in realtà non so molto di registri e prescaler e quindi ho una domanda.
Vorrei impostare una frequenza di 10kHz su quei pin, è possibile modificare solo il valore OCR5A e ottenere 10kHz tenendo il system clock? O c'è un prescaler da impostare che mi aiuti a andare molto più vicino alla frequenza desiderata? Che cosa cambia(o meglio come si procede)?
//arduino mega2560 Timer5
//here is my code where I generate 799,92Hz freq, PWM of
//75% on OC5B and PWM of 75% on OC5C with clock system
//phase & freq correct PWM
int outputB = 45; //D45
int outputC = 44; //D44
void setup()
{
//outputs via timer5
pinMode(outputB, OUTPUT); // select Pin as ch-B
pinMode(outputC, OUTPUT); // select Pin as ch-C
TCCR5A = B00101001; // Phase and frequency correct PWM change at OCR5A
TCCR5B = B10001; // System clock
OCR5A = 10000; // 799,92Hz
OCR5B = 7500; // 75%
OCR5C = 7500; // 75%
}