Download Make: AVR Programming
Transcript
Getting Started: Blinking LEDs MCU This is the type of AVR chip you’re using. In our case, we’re using an ATmega168, so it reads atmega168. For a complete list of supported chips, type avr-gcc -target-help and about halfway down you’ll find a list of “Known MCU names.” F_CPU This definition tells the compiler what clock speed your chip is running at. If you don’t have an external clock source, like a crystal, this is either 1,000,000 or 8,000,000 for the ATmega chips—one megahertz or eight megahertz. Getting this right will matter for the timing of serial communication, and anything else where timing is key. BAUD This is the baud rate that you’re going to use for computer-to-AVR serial communications, and 9,600 baud is a good conservative default. MAIN This entry is just the name of the program that you’re compiling and flashing —the code that contains the main() routine. I’ve filled this in for you in the book’s projects, but if you want to start a new project from scratch but reuse this makefile, you’ll need to change the MAIN. LOCAL_SOURCE Here you have the chance to list any other .c files that your main code section needs to run. Again, I’ve filled these in for the book’s projects, but I mention it here in case you’d like to see how to include multiple files in your compilation. EXTRA_SOURCE_DIR and EXTRA_SOURCE_FILES This is an option to include code that lives in another directory or folder somewhere on your system. We’ll use this a lot for including my USART.h standard serial library. PROGRAMMER_TYPE The two “programmer” options are for AVRDUDE, along with information about what chip we’re programming from MCU. Here, you enter the type of flash programmer that you’re using, and the makefile passes it to AVRDUDE using the -c option. If you’re using a USBTiny or USBasp, for instance, you enter that here. If you’re using the Arduino as a flash programmer, enter avrisp. PROGRAMMER_ARGS The other “programmer” option is for any of the other necessary AVRDUDE options. If you’re using a USBTiny or USBasp, you won’t have to enter anything here; just leave the line blank. If you are using a serial-based programmer, you’ll need to specify the serial port and baud rate using the -P and -b options, respectively. Chapter 2: Programming AVRs 39