According to the datasheet, pins 11, 12, and 13 are PWM pins on the Attiny 2313. However, analogWrite() only seems to work on 11. If I vary the value written using analogWrite from 0 to 255, the LEDs on pins 12 and 13 only flash on at the end.
I am using ATTinyCore to program the chip, and I've tested the chip with other simple programs, all of which seem to work as planned. Is this expected behavior? If not, why are pins 12 and 13 not functioning as PWM pins?
Because of the limited flash space on those chips, Timer1 isn't initiated by default. There are more details here, but the relevant part is below:
Initialize Secondard Timers option
When an Arduino sketch runs, prior to Setup() being called, a hidden init() function is called to set up the hardware. One of the things it does is configure the timers. Timer0 (used for millis) is always configured, but on the x313 series, due to the extremely limited flash, it is optional whether to initialize Timer1. If Timer1 is not initialized, Tone() and PWM on pins 12 and 13 will not work.
fadecomic:
Aw, man, I looked at those docs, too. I didn't realize there were other docs beyond the main one. Thanks.
sigh....
ATtinyCore Universal
This core supports the following processors - essentially every ATtiny processor that makes sense to use with Arduino. Click the processor name for part-specific information: