So I got the duemilanove (328p) and while I love and appreciate the simplicity of the arduino IDE and concept, I would also like to "get intimate" with my 328p chip by doing a few programming exercises on it without the arduino training wheels. And I just wanted to document my findings here in case anybody else wanted to do the same.
First issue: how to get the code from AVR Studio onto the chip without a jtag/programmer?
(I can't remember where I found this tip but somewhere on this forum)
First make a project in AVR Studio, pick any programmer for your chip I guess. Try compiling some code, for example from the chip datasheet, and see where your files end up. We are interested in the *.hex file being generated here. If you haven't chosen any path try looking in my documents or similar directory.
In AVR Studio: Tools -> Customize (opens windows) -> Tools (tab).
Make a new tool (name it AVRdude or whatever).
Command: avrdude
Arguments: avrdude -p m328p -P com3 -c arduino -b 57600 -F -u -U flash:w:REPLACEWITHYOURFILENAME.hex
Initial Directory: the path to the folder containing your .hex file
Obviously the arguments will be different if your not using the 328p chip. See this site for other chips AVRDUDE: 2.2 Programmers accepting extended parameters
Now when you want to load the program to your chip (this should not remove the arduino bootloader), you simply go to Tools -> AVRdude (or whatever you named it). I'd recommend you try flashing via command prompt if it doesn't seem to be working, so you can see any errors it throws.
I guess if you got a JTAG you would be able to step through the code and all that stuff, but I don't have one.
Second issue: WTF? All these pin numbers on the arduino breakout board have nothing to do with the chip datasheet?!!
Right.. So the arduino IDE/bootloader for example knows that "pinMode(13, OUTPUT);" is actually pin 19 (PB5 in the datasheet), but when programming without using the arduino functions you need to know whats what on your breakout board yourself. I couldn't find any way to determine this other than either a lot of testing, or scrutinizing the arduino duemilanove board layout (the schematic didn't seem to help in this regard). So to save others in my situation some time, I will share my findings (these are not tested).
I was going to post a table directly here, but that turns out to be way too much hassle so I will redirect you to this Gdocs spreadsheet instead.
goo.gl/5utI
This might be obvious to many, and it might be well documented someplace that I just haven't seen, it just took me some time to figure all this out so I decided to make this post.