Arduino 16 bit PWM
void setupPWM16() { DDRB |= _BV(PB1) | _BV(PB2); /* set pins as outputs */ TCCR1A = _BV(COM1A1) | _BV(COM1B1) /* non-inverting PWM */ | _BV(WGM11); /* mode 14: fast PWM, TOP=ICR1 */ TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); /* no prescaling */ ICR1 = 0xffff; /* TOP counter value */ } /* 16-bit version of analogWrite(). Works only on pins 9 and 10. */ void analogWrite16(uint8_t pin, uint16_t val) { switch (pin) { case 9: OCR1A = val; break; case 10: OCR1B = val; break; } }
or using timer1 library
Timer1.initialize(5000) Timer1.disablePwm(10); //WiServer needs pin 10! Timer1.pwm(9, 0); //set up pin 9