No, you cannot do that. The pins are not 5v tolerant, take a look at the diagram at the start of the IO port section of the datasheet.
There are protection diodes between each pin and Vcc, that will prevent the pin from rising much above Vcc; these are not meant to carry much current though (iirc you're supposed to keep it below 1mA), and so will be damaged. If there's very little load on the 3.3v, the 3.3v will get pulled up to something higher than 3.3v through the protection diode in the process.
PaulRogers:
I should have specified I was talking about ATTiny 85 and 84 that you can choose to run at up to 5.5v or down to 2 or so volts at lower clock speed.
So I meant running an ATTiny 85 or 84 at 3.3v but still sinking 5v.
rather than more generically any ATTiny.
I know, you cannot do that, an ATtiny (or almost any other 8-bit AVR chip) at 3.3v is NOT 5v tolerant!
Use transistors to switch the 5v, run the tiny at 5v, or run the load at 3.3.
OK, thanks for replies, I was kind of imagining it as water pressure and that 5 at a junction would overpower a supply of 3.3... (unless you had some backflow gates, which I guess do not exist in electronics such that it detects a flow backwards greater than supply and the flow itself closes the physical gate... in itself a tricky spring pressure problem eh!)
so transistor can only block to supply level or something....
voltage divider then...
is there a similar voltage amplifier circuit, guess that's an op-amp... like 3x3.3/2 (bomdas or bodmas or left to right or light to left LOL)
I know it’s a bit late, but the ‘flow back gate’ that you were talking about with the water analogy does exist in the form of a schottky diode - Google it