Program a fresh atmega328p chip with arduino IDE

i have been searching about how we can use the arduion IDE (0019) to program and compile to a .hex file. Then upload this .hex file to a brand new virgin atmega328p in AVR Studio (4.18) through an AVRISP mkII. Many topics were about how to use Arduino board as ISP. But i want the other way around. The closest topic about what i want is:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264365471/7

p.s.

  1. the atmega328p-au (not the DIP one) is fresh, no arduino bootloader, only programmed for a few times with the AVR Studio and AVRISP mkII for some simple ADC and USART programs.

  2. assuming the atmega328p-au has the same fuse bits (attached with a 16Mhz crystal) and lock bits setting as the atmega328p-pu on the arduino duemilanove board.

Extra question: :stuck_out_tongue:
if i change the crystal to 20Mhz, which is supported by the atmega328p-au by the way, does it mean i can't use the arduino IDE to write and compile my desired program any more, or i just need simply to redefine the F_CPU to be 20000000UL ??

if this method really works, then i can just work with arduino sketch, which i m more familiar with. LOL
thank you in advance!! ;D ;D

Search the forum for 20mhz arduino, there are some patches to the ide floating around that allow 20mhz. I don't know much else about them.

actually, i think i succeeded in compiling a compatible hex code for the mcu i using. I just create a new entry to the arduino IDE to select as a new arduino board with the fuse and F_CPU settings exactly the same as the one i using. Then all went fine!! Thanks anyway