PaulStoffregen / TimerOne

TimerOne Library with optimization and expanded hardware support
http://www.pjrc.com/teensy/td_libs_TimerOne.html
470 stars 209 forks source link

Inverted PWM #40

Open vangalvin opened 5 years ago

vangalvin commented 5 years ago

Is there an option for inverted PWM? I have a motor driver that requires an inverted PWM signal of around 32Khz.

JensGrabner commented 5 years ago

I use these: Timer1.initialize(Time_LOW); // sets timer1 to a period of "Time_LOW" microseconds TCCR1A |= (1 << COM1B1) | (1 << COM1B0); // inverting mode for Pin OC1B --> D4 Timer1.attachInterrupt( timerIsr ); // attach the service routine here Timer1.pwm(13, duty_cycle); // "duty_cycle" goes from 0 to 1023 works fine with ATmega1284 or ATmega1284p.