I am trying to make a simple attiny circuit that switches 5V through PWM into 3.2V. The load will be a vape coil that draws 2A at 3.2V, so the 490Hz PWM signal is fine. When I tested the circuit with an LED that draws ~1A at 3.2V, the LED just flashed on and off quickly, as if the attiny was resetting itself. I tested the mosfet with a pwm generator, and it worked fine. What it happening?
that switches 5V through PWM into 3.2V
No it isn't. Voltage doesn't behave like that. 5V switched on and off with a 64% duty cycle is not 3.2V. It's still 5V, you're just turning it on and off. You're getting 5V for ~1.3 milliseconds followed by 0V for ~0.7 milliseconds, over and over, 490 times per second.
Current is equal to voltage divided by resistance, while power is equal resistance multiplied by the square of the current.
5V/1.6Ω = 3A, and the power dissipated is 1.6Ω*3A*3A = 14.4W. Even though it is only on 64% of the time, 14.4W*0.64 = 9.2W. Whereas if the coil was being powered by 3.2V only, it would dissipate only 6W. PWM by itself does not have any effect on the voltage, and is only turning it on and off, and this does not result in proportional current flow or power.
In the case of the LED, it is not resistive and current increases exponentially as voltage goes above the forward voltage. That LED might draw 2A at 3.2V, but you aren't giving it 3.2V, you're giving it 5V (for 64% of the time). A 3.2V LED that is designed to draw 2A at that voltage is going to draw substantially more than 2A or even 5A with 5V across it. It doesn't matter if that voltage is only across it 64% of the time or 1% of the time - it will draw way more than 2A.
So your ATTiny is behaving as if it is resetting itself because that's exactly what it is doing. The LED is likely causing the power supply to protection mode or cause the voltage to drop out, triggering the brown-out protection on the ATTiny, which results in a reset.
Your circuit may work if you try it with the vape coil instead, but it will dissipate closer to 10W, not 6W.
It would be far easier to simply wind a new vape coil from Kanthal resistance wire such that it will dissipate 6W when run off 5V - a resistance of about 4.1-4.2Ω would do the trick.
Probably your power supply is unable to supply the load - every time the load is turned on the supply voltage drops and causes the processor to reset.
You need a more capable supply or a separate supply for the load.
You also need to ensure the supply is adequately decoupled to minimize supply transients.
Be careful about the arrangement of wiring - the inductance and resistance of the power leads can cause voltage drops or surges as the current changes.