I want to use this to generate a 1.6Mhz frequency.
However, I can't get that high. I can only racy 150khz.Here is my code.
#include <timer.h>
void setup() {
SerialUSB.end();
systick_disable();
pinMode(0, OUTPUT);
digitalWrite(0, LOW);
timer_pause(TIMER1);
timer_set_mode(TIMER1, TIMER_CH1, TIMER_OUTPUT_COMPARE);
timer_set_prescaler(TIMER1, 1);
timer_set_reload(TIMER1, 72);
timer_set_compare(TIMER1, TIMER_CH1, 1);
timer_attach_interrupt(TIMER1, TIMER_CH1, handler1);
timer_generate_update(TIMER1);
timer_resume(TIMER1);
}
void handler1() {
togglePin (24);
}
I notice someone discuss here
http://forums.leaflabs.com/topic.php?id=834#post-4977
I think what robodude666 said could solve my problem.("checkout the source behind the timer's interrupt handlers") But I don't know how to do it.
Could anyone told me how to do it?
I am really green hand to this area.
Thanks,