PB3 as PWM in Attiny85?

Hi! I’m doing a circuit in an Attiny85 with PB0 and PB2 are in an I2 C sensor, PB1 is a green led (that can be pwm’d), PB5 (reset disabled) is an analog input for voltage reading, PB4 is a PWM output for a 3W led.

I wanted the PB3 pin to be also PWM for fading a red led.

I read it’s possible by creating an interrupt to make the PB3 a pwm pin. But can it become a PWM pin without affecting millis(),I2c and the PWM of PB4??

I read that they are complementary, so when PB3 (as pwm) is at 10% PB4 would be at 90%.

Is that true? Is it possible to make PB3 an... independent PWM out pin, with no side effects?

Thanks!

Nobody??

The ATtiny85 data sheet explains the various possible uses of timers 0 and 1. You need to check for conflicts with the Arduino core.

PB3 PWM output is simply inverted PB4 PWM output.

There is the dead time generator so PB3 is not simply inverted PB4. I have never used it but from the description the dead time generator cannot be used to get all possible duty cycles on both pins - it can extend the time a pin is LOW but not HIGH.

Also interrupts can be used to generate the PWM on PB3 (or any other pin). It will be CPU intensive if high frequency is needed and introduce some jitter and very high or low duty may be problem but it is possible.

As noted, you cannot generate arbitrary PWM on PB3, only an inverted version of what's output on PB4 (less the dead-time). It's not clear to me from the datasheet whether it is possible to generate PWM on PB3 without ALSO generating PWM on PB4, though - my interpretation is that it is not: there's no setting of the COMxn bits that enables the inverted PWM but not the non-inverted PWM...