A few weeks ago, I got my arduino UNO, and for my first project I wrote a simon game clone. I don't need a simon game, I just figured it'd be a good learning experience. When I had finally gotten it all set up and working on a breadboard, I decided to continue the learning experience.
I knew the breadboard wasn't going to cut it, and I didn't think a protoboard was going to be much better. I decided to learn EAGLE, and I now have a basic understanding of how to use it to design a PCB.
The first PCB design I made included one of the SparkFun Pro Mini boards, but it occurred to me, why do I need a whole arduino board? I could just get an atmega328 chip and use it as a standalone in my design. Then I got to thinking some more, if I'm not using an arduino board, why use an atmega328 chip when it's totally overkill for this project. I looked around on the internet, and found that people have been using the attiny44 to power simon games, and it seems much more suited to this application. However, it didn't seem like you could buy it with any sort of Arduino bootloader or related support.
So now I've been searching around, and I guess I don't need Arduino at all for this project. I could buy a programmer like the sparkfun AVR pocket programmer, or the AVR dragon or something, and program any AVR chip however I want.
(TL;DR) My questions are these:
If I program the AVR fuses to use an external 16mhz crystal, do I have to have the 16mhz crystal attached in order to program it? Do I have to have some of my circuit set up in order to program the AVR, or can I just plug the AVR into the programmer, and then move it to my project once it has been programmed?
I looked around on the internet, and found that people have been using the attiny44 to power simon games, and it seems much more suited to this application.
Do I have to have some of my circuit set up in order to program the AVR, or can I just plug the AVR into the programmer, and then move it to my project once it has been programmed?
Program then move is fine. But it makes debugging significantly more time consuming.
A bootloader allows the processor to reprogram itself. From the perspective of the outside world, the bootloader talks a protocol named "STK500". The protocol essentially consists of commands like "write these values to those memory locations" and "send me the value from that memory location". Primarily the bootloader translates that protocol to memory reads and writes. (Which means that, without "lock bits", the bootloader could actually overwrite itself.)
I have looked at the links - I think I understand how to use the UNO as a programmer, though I still don't understand, if the UNO can speak ISP, why does the bootloader need to be there? Why couldn't it just flash the whole chip every time?
What are the advantages of using a bootloader over having the programmer built into the board?
synic:
I have looked at the links - I think I understand how to use the UNO as a programmer, though I still don't understand, if the UNO can speak ISP, why does the bootloader need to be there? Why couldn't it just flash the whole chip every time?
You could. But if a specific project is using the serial port to comm with the PC anyway, then the ability and convenience of being able to quickly upload a change or a whole new sketch without having to go through the extra steps of uploading the arduinoISP sketch to another board that is then hardwired to the target board, should not be ignored. Either may be the best choice for a given project or phase of development for that project.
What are the advantages of using a bootloader over having the programmer built into the board?
I'm not aware of a 'board' that is both a ISP programmer and a AVR chip to run the sketch at the same time. A loaded bootloader makes uploading a sketch and running the sketch a single board operation using the IDE. Uploading via ISP using the IDE upload using programmer option requires a second board (module, or hardware programmer) that then has to be connected to the 'target' board. That is a significant difference. Having a choice, the options available, is always the correct answer.
synic:
What are the advantages of using a bootloader over having the programmer built into the board?
The bootloader is the programmer. It activates first on reset and waits briefly to see if there are programming instructions coming in, in which case it writes the downloaded code into the rest of the flash memory (and then executes a reset). If no download instructions come in, it starts the code which has been downloaded beforehand.
synic:
if the UNO can speak ISP, why does the bootloader need to be there? Why couldn't it just flash the whole chip every time?
The UNO - or just about any other Arduino - can run a sketch (loaded first using its bootloader) which then allows it to function as an ISP programmer not to itself, but to another Arduino board or breadboarded MCU. (Actually, the Uno R3 can do something rather interesting since it actually has two MCUs.)
It should also be obvious that if the bootloader was able to over-write itself (by flashing the whole chip), then it would fail to function at that moment, and you would then be unable to load another sketch when desired.
Sorry, I forgot to reply to this. I'm a terrible person.
Thank you for the information! I get that in order to use ICSP instead of the bootloader, you'd have to have two UNOs - one to program the other.
I ended up just getting the AVR Pocket Programmer from SparkFun. I want to delve deeper into the world of programming all the available AVR controllers there are, so I can pick the appropriate specific one for whatever project I may be working on.