Frecuencia PWM del Arduino



cli(); //disconnect interrupts

// Non-inverse output mode
TCCR1A|=(1<<COM1A1); //1
TCCR1A&=~(1<<COM1A0); //0

// shear mode with exact phase and frequency
TCCR1A&=~(1<<WGM10); //0
TCCR1A&=~(1<<WGM11); //0
TCCR1B&=~(1<<WGM12); //0
TCCR1B|=(1<<WGM13); //1

// Dividend 8
TCCR1B|=(1<<CS11); //1
TCCR1B&=~((1<<CS10)|(1<<CS12)); //0 0

OCR1A =25; // 50% pulse duration
ICR1=50; // 20kHz

sei(); // interrupt resolution