I want the timer work at the PWM mode and produce a 1.6Mhz frequency.
This is the code I write.
However, it do not work correctly and only produce a 549.5 Hz frequency.
which is the initial PWM frequency, I guess. The timer do not work.
Could anyone told me how to fix it?
#include <timer.h>
HardwareTimer timer(4);
void setup() {
pinMode(0, PWM);
pinMode(24, PWM);
pinMode(28, PWM);
Timer4.pause();
Timer4.setPrescaleFactor(1);
Timer4.setOverflow(45);
Timer4.setChannel4Mode(TIMER_PWM);
Timer4.resume();
Timer4.refresh();
}
void loop() {
}