SpenceKonde / ATTinyCore

Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8
Other
1.59k stars 308 forks source link

Support for using Timer1 output compare A for Tiny85 #289

Closed SpenceKonde closed 5 years ago

SpenceKonde commented 5 years ago

Add menu option to select timer source for PWM on PB1.

Add support for Tone to directly drive that pin with output compare if that option is selected.

SpenceKonde commented 5 years ago

I have adjusted tone() to use hardware output compare on pin 1 (PB1). I stopped short of adding the menu option that would make analogWrite() pwm on pin1 use timer1. Users have complained about the number of submenus for chip-specific options causing confusion, and making it possible to use timer1 for analogWrite() on pin 1 didn't justify the confusion - if you're doing fancy stuff with timer1 such that you want to use timer1 instead of timer0 for pwm on pin1, you probably need more control than analogWrite() would give you anyway.

I also considered just setting pin1 to always use timer1 for pwm, but I decided against it because then tone() would take out pwm on that pin, when the benefit of doing this wasn't compelling.

Let me know if this doesn't solve your problem.