Install Arduino bootloader on ATMega328P Don’t use example sketch instead use : http://www.gammon.com.au/bootloader run from serial monitor.