Atmega328 freezes

Set it up as shown below, and it will work fine. As you have taken the IC out of your arduino, it wil already have a bootloader on it, so ignore the bootloader burning bit.

Onions.