■ FIGURE 4. Project Options - General.
#elif (defined(Arduino) || defined(BeAVR40))
#define F_CPU 16000000L
#define BAUD 57600
#error “F_CPU and BAUD undefined”
These #if conditions set the bootloader baud rate. If
none of the devices are defined, it causes the compiler to
generate the following error:
../SmileyFlashTest.h:105:3: error: #error “F_CPU
and BAUD undefined”
The F_CPU and BAUD are used to calculate the
baudrate in the USARTInit() function in the source code.
This function also uses the #if #elif preprocessor directives
to select and set other device-specific USART registers.
IMHO you have to be careful how you use the
preprocessor or you can get nearly unreadable source
code. I have at times had to go through other people’s
code and delete all the conditional statements that
■ FIGURE 6. Project Options - Memory.
weren’t relevant to the
device I was using just
so I could follow the
logic of their code. The
is a bit like this IMHO,
though not nearly as bad
as some I’ve come across.
Since I plan to keep future Workshops to the three devices
listed, we can hope that the code won’t get too cluttered.
■ FIGURE 5. Add New
Using AVRStudio To Compile
And Load FlashWriter
AVRStudio now has features that allow you to compile
programs without having to mess with a Makefile. We will
set some Project Options and will make sure that the
correct fuses are set in our AVR Programmer.
Settings for Project Options.
In the AVRStudio Project menu, open Configuration
Options. In Figure 4, we see the General page set for the
ATmega644p used in the BeAVR40.
Setting the Memory Settings.
Open the Memory Settings panel and click on the Add
button. In the Add New Memory Segment dialog shown in
Figure 5, select Flash, type in the name “.text” making sure
to include the preceding dot in .text, then set the address to
■ FIGURE 7. Display Connect Dialog.
■ FIGURE 8. Select AVR Programmer.