I am a brand-spanking-new Newbie to the Arduino community, and I like what I have experienced so far! I wished I had known about Arduino during my senior thesis days!! I had to teach myself AVR programming using AVR Studio and the STK-500. A lot of headaches I had!
I have several questions on the feasibility of transitioning from Arduino development/evaluation to ISP of an AVR on my final PCB. Below are the details:
I am currently trying to develop the needed software using an Arduino Nano 3.0 USB (Atmega328p) evaluation board.
At the same time, I am designing a PCB in EAGLE with an Atmega328P (32-pad QFN/MLF package) on-board.
I am putting ISP ports (via a 6-pin Molex picoBlade) on the PCB to help program the Atmega328P (after it has been soldered on by ScreamingCircuits).
So, my question is:
A) Can I use the AVRISP mkII programmer with the Arduino software?
B) Will I need to burn some kind of Arduino firmware onto the newly purchased Atmega328P in order to use it with the Arduino Software?
C) Could a hex file from the Arduino software (I haven't tried looking for one yet) be used to program the newly purchased Atmega328P via AVRISP mkII?
d) Would Atmel's FLIP programmer be of any use with the situations detailed above/
So, my question is:
A) Can I use the AVRISP mkII programmer with the Arduino software?
Yes, I think that is one of the programmers listed in the burn bootloader pulldown menu, so the IDE and avrdude 'knows' about that programmer. Note that to burn sketches directly to a board using a ISP programmers and using the IDE upload button, requires editing a line or two in the boards.txt file, as all the exisiting board definitions assume the target is using arduino bootloader code and a serial comm connection to perform the upload. Easy mod as I recall.
B) Will I need to burn some kind of Arduino firmware onto the newly purchased Atmega328P in order to use it with the Arduino Software?
Not if you are planning on using a ISP programmer as your method of uploading sketches. If you were instead going to use the normal arduino upload method using the USB serial connection, then any blank chip would have to have the proper arduino bootloader code loaded in prior.
C) Could a hex file from the Arduino software (I haven't tried looking for one yet) be used to program the newly purchased Atmega328P via AVRISP mkII?
Yes, it use to be easier to find as the hex file was saved in the sketch folder. However now you have to hold down the shift key when you verify the sketch and if it compiled successfully there will be a temporary folder path shown where the hex file can be located and you can copy it to some safer place as it goes away when the IDE is closed. Note however that the arduino IDE has no load hex file option, it's has only a compile and upload method, however one can use the embedded AVRDUDE software in command line mode to directly load a hex file via your programmer.
d) Would Atmel's FLIP programmer be of any use with the situations detailed above/
If you were instead going to use the normal arduino upload method using the USB serial connection, then any blank chip would have to have the proper arduino bootloader code loaded in prior.
Oh... every time I parsed through the forum and saw the word "bootloader", I assumed it was the translation code between Arduino and embedded C language. That's why I was thinking that a plain-Jane Atmel chip couldn't work with Arduino stuff unless this "bootloader" thing was on the chip first... embarrassing!!
After recollecting on the past few days (that's how long I've been exposed to this!), I see now that Arduino is a simple-to-use and understand IDE that has wonderful libraries that are easy to utilize in embedded C programming.
Note that to burn sketches directly to a board using a ISP programmers and using the IDE upload button, requires editing a line or two in the boards.txt file, as all the exisiting board definitions assume the target is using arduino bootloader code and a serial comm connection to perform the upload. Easy mod as I recall.
Cool... so I just need to find out which lines to edit in boards.txt to perform in-system programming on my PCB using AVRISP mkII.
However now you have to hold down the shift key when you verify the sketch and if it compiled successfully there will be a temporary folder path shown where the hex file can be located and you can copy it to some safer place as it goes away when the IDE is closed.
Or, I guess I can just get that hex file and upload it to the on-PCB Atmega328P using Atmel's FLIP software. It's just a simple hex file uploader (no compiling or editor) for the AVR chips.
Nevertheless, I'm very happy to know that I can directly transition from the Arduino Nano 3.0 to my PCB Atmega328P without any headaches.
You're forgetting one thing -- when you get fresh boards delivered with never-before-programmed ATMEGA328P's, you need to program the fuses to settings of your liking. You can do this with AVR Studio. I think the Default Settings for Arduino boards are:
Extended 0xFD
High 0xDA
Low 0xFF
You can use AVR Studio to 'read' these settings from an existing arduino as well. You also need to set the AVR ISP MKII speed to 125khz for the first write of these fuse values. After that you can jump up to 2MHz.
You're forgetting one thing -- when you get fresh boards delivered with never-before-programmed ATMEGA328P's, you need to program the fuses to settings of your liking. You can do this with AVR Studio. I think the Default Settings for Arduino boards are:
Extended 0xFD
High 0xDA
Low 0xFF
So, just to verify: are you defining "fresh boards delivered with never-before-programmed ATMEGA328P's" as the Uno, Fio, Nano, MEGA 3280, etc..? If so, then I am not making a PCB board that will be identical or even similar to these Arduino designs.
But, I am designing a PCB board that will use an Atmega328P purchased from Digikey. My intentions are to develop/practice my embedded C code on the Arduino Nano v3.0 and then burn the final code (or hex code, depending on method) to the Atmega328P on my newly designed PCB board via AVRISP mkII.
So, are you saying that even if I am not making an Arduino board like the Uno, Fio, Nano, etc...., that I will still need to program the fuses in a fresh Atmega328P microcontroller before I burn the final code?
So, are you saying that even if I am not making an Arduino board like the Uno, Fio, Nano, etc...., that I will still need to program the fuses in a fresh Atmega328P microcontroller before I burn the final code?
Yes, a so called 'fresh' 328p will ship from the AVR factory with a certain default fuse setup (like using the internal R/C oscillator as the clock source. Depending on how you want to set up the standalone board you use you will have to set the fuses to the configuration you want, like external crystal or ceramic resonator, no bootloader memory protect option, etc. These fuses can be setup with your AVRISP programmer using software other then the IDE, as the IDE will only burn fuses during the burn bootloader operation, not the normal upload operation where it assumes the fuses are already configured.
I think it's possible with the correct software to program the fuses and load the program via ISP programmer is the same session, but again that's not something you can do from inside the arduino IDE, I think.
Yes, a so called 'fresh' 328p will ship from the AVR factory with a certain default fuse setup (like using the internal R/C oscillator as the clock source. Depending on how you want to set up the standalone board you use you will have to set the fuses to the configuration you want, like external crystal or ceramic resonator, no bootloader memory protect option, etc.
Ok, cool... I've been debating between using the on-chip RC oscillator or a crystal resonator as my clock source. My application is not really require a perfect clock source. Nevertheless, I will look at the Atmega328P datasheet for the necessary fuse settings.
So, how about the previous quote?
I think the Default Settings for Arduino boards are:
Extended 0xFD
High 0xDA
Low 0xFF
Will these fuses need to be set on a fresh Atmega328P in order to upload software code via the AVRISP mkII on a newly designed PCB board (using the 6-pin ISP header port; I have not designed my PCB board with USB support, just the 6-pin ISP lines to the Atmega328P chip)?
Or, are the above fuse settings just for Arduino boards with Atmega chips which need the bootloader for USB programming?
Or, are the above fuse settings just for Arduino boards with Atmega chips which need the bootloader for USB programming?
That is the case. However not all fuse settings have to do with using a bootloader in protected memory or not, some deal with clock source, some deal with brown out power reset value to use, etc.
Fuse settings and their applicablity to ones requirements can be a little complex and errors in burning fuse settings can 'brick' the chip, requiring a high voltage programmer to restore. The Atmel 328p datasheet is a must read to master fuse settings.