The purpose of this applic at ion note is to
guide new users through the initial settings of the Embedded Workbench from
IAR and compile a simple C progr am.
The application note sho ws how t o set
up the compiler to generate an executable hex file and how t o downlo ad this
file into the device. The example
described in this application note is written for the AT90S2313 using the
STK200 starter kit or alternati vely an
emulator.
Figure 1. Create the Project File
Preparations
The IAR compiler is shipped with a hardware lock dongle. This dongle must b e
connected to the parallel port. Before the
dongle can be used, a windows driver
must be installed. Please see the
instructions included with the dongle for
how to install the windows driver.
Creating a New Project
When the preparatio ns are ready , open
the IAR Embedded Workbench. To create a new project, go to the “File” men u
and select “New” and then “Project”. The
dialog box shown in Figure 1 appears. In
this dialog box, first make a folder
“C:\ AVR030” and then type “Getting
Started” in the “File name” window. This
project should be created in the in the
“C:\AVR030” folder.
8-bit
Microcontroller
Application
Note
Rev. 1483A–09/99
1
Settings in “Project-> Options”
Before any cod e can be comp iled and li nked, the opt ions
for the compiler and linker must be set up correctly. By
default, it is possible to select two different targets in the
project window. The two selections are target “Release”,
and target “D ebug”. The debug target is normally used
when running the code in a simulator or emulator, while the
release target is normally used when producing a code that
can be executed in a real device. The settings done in the
“Project->Options” menu are individual for both targets.
Thus, it is necess ary to set al l options twice when usin g
both targets. The main difference between the two targets
is the format of the output file.
Figure 2. Selecting Target Release
It is also possible to add more targets which options can be
customized to a specific A VR (simulated, emu lated or the
real device). Common and different source files may be
included in the diffe rent targets . A fold er wil l be create d for
each target when linked for the first time.
In this application note, the goal i s to make a file that can
run in the AT90S2313 device. To do this, the release target
will be used. Select the “Release” target in the “Getting
started.prj” window as shown in Figure 2. T hen select the
“Project->Options” menu. The window shown in Figure 3
will pop up.
General Settings
In the “General” category in the “Options” dialog box, the
type of processor used is selected. It is necessary to
change two settings, “Processor Configuration” and “Mem-
ory Model”. Please refer to Table 1 for the correct selection
for these choices for different AVR microcontrollers.
“Memory model tiny” uses a one byt e data pointe r, thus
allowing a maximum of 256 bytes data. “Memory model
2
AVR030
small” uses a two byte data pointer, thus allowing up to 64
Kilobytes data. For the -v0 and -v2 “Proce ssor Configuration only the Memory model tiny” may be used.
In our example, the factory settings should be used, as
shown in Figure 3.
To get the dialog options for the specific settings of the
Compiler, click on the “ICCA90” line in the “Category” tab.
When using the memory model tiny, the factory settings are
OK.
If the memory model small is selected, it is necessary to
check the “Writable strings, constants” checkbox. If this is
not done, vari ables def ined as c onst will not be com piled
correctly. Figure 4 describes the settings when the memory
model small is selected.
The compiler may be optimized for code size or execution
speed. The type and level of optimization may be set in the
“Optimization” group in Figure 4. Only one type of optimiza-
tion may be speci fied fo r a single target . Note t hat if a hig h
level of optimization is used, the user may not be able to
debug the code. The code will be fully debuggable with
Small
Small
Small
128F4KS.xcl
128F64KS.xcl
16F1KS.xcl
16F64KS.xcl
64F4KS.xcl
64F64KS.xcl
optimization level 3 (default for both types of optimization)
or lower.
Also note that it i s strong ly reco mmende d that the “Embed
source” code chec kbox in the “Debu g” tab is checked if a
debugging target, i.e. simulation or emulation, is used. This
will let you debug on the assembly level rath er than on th e
C language level. In AVR Studio you wil l also be able to
see exactly which assem bly code is gen erated for the individual C statements.
On the “List” tab, the user is able to determine whether a
listing is generated, and the information included in this listing. The “Insert mnemonics” option will, i f checked, cause
the compiler to inc lud e th e ge ner ate d as sembly lines in the
listing.
4
AVR030
Loading...
+ 7 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.