TO OUR VALUED CUSTOMERS
I want to express my thanks to you for being interested in our products and for having
confidence in MikroElektronika.
The primary aim of our company is to design and produce high quality electronic products
and to constantly improve the performance thereof in order to better suit your needs.
Nebojsa Matic
General Manager
ARM
®
and Windows
®
logos and product names are trademarks of ARM
®
Holdings and Microsoft
®
in the U.S.A. and other countries.
Table of Contents
1. Introduction to mikroC PRO for ARM
®
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 04
2. Hardware connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 05
3. Creating a new project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 06
Step 1 - Project settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 07
Step 2 - Add files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Step 3 - Include libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Step 4 - Finishing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Blank new project created . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4. Code example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5. Building the source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6. Changing project settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
7. What’s next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Page 3
1. Introduction to mikroC PRO for ARM
®
mikroC PRO for ARM
®
organizes applications
into projects consisting of a single project file
(file with the
.mcpar
extension) and one or
more source files (files with the .c extension).
The mikroC PRO for ARM
®
compiler allows you to
manage several projects at a time. Source files
can be compiled only if they are part of a project.
07
02
01
06
A project file contains:
• Project name and optional description;
• Target device in use;
• Device clock;
• List of project source files;
• Binary files (*.emcl); and
• Other files.
In this reference guide, we will create a new project,
write code, compile it and test the results. The
purpose of this project is to make microcontroller
PORTA LEDs blink, which will be easy to test.
03
05
04
08
01
Main Toolbar
02
Code Explorer
03
Project Settings
05
Code Editor
04
Messages
06
Image Preview
07
Project Manger
08
Library Manager
Page 4
2. Hardware connection
VCORE
VCC-3.3
Let’s make a simple “Hello world” example for the
selected microcontroller. First thing embedded
programmers usually write is a simple
LED blinking
program. So, let’s do that in a few simple lines of C code.
LED blinking is just turning ON and OFF LEDs that are
connected to desired PORT pins. In order to see the
example in action, it is necessary to connect the target
microcontroller according to schematics shown on
Figure 2-1.
In the project we are about to write, we
will use only
PORTA,
so you should connect the LEDs
to PORTA only.
VCORE
AVCC
100
99
98
97
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
79
78
77
76
U1
PD7
PD6
PD5
PD4
PE3
PE2
GND
VDD
PB4
PB5
PB6
PB7
VDDC
PJ1
PH0
PH1
PH2
PH3
GND
VDD
PC0
PC1
PC2
PC3
PH4
Figure 2-1: Hardware
connection schematic
VCC3
E9
10uF
PA0
PA1
PA2
PA3
PA4
PA5
VDD
ERBIAS
PA6
PA7
PG7
RXIN
VDDC
PJ2
RXIP
PF5
PF4
TXOP
VDD
GND
TXON
PF0
OSC0
OSC1
PJ3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
PE7
PE6
VDDA
GNDA
PE5
PE4
LDO
VDD
GND
PD0
PD1
PD2
PD3
PJ0
PH7
XTALPPHY
XTALNPHY
PG1
PG0
VDD
GND
PC7
PC6
PC5
PC4
LM3S9B95
PE1
PE0
USB0BIAS
PB2/I2C0SCL
USB0DP
USB0DM
GND
VDD
PB1/USB0VBUS
PB0/USB0ID
PB3/I2C0SDA
RST
PH5
PH6
PF1
PF2
PF3
MDIO
GND
VDD
PJ7
PJ6
PJ5
PJ4
NC
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
56
55
54
53
52
51
R1
4K7
R2
4K7
R3
4K7
R4
4K7
R61
9K1
LD0
LED
LD1
LED
LD2
LED
LD3
LED
PA0
PA1
PA2
VCC3
R5
4K7
R6
4K7
R7
4K7
R8
4K7
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
LD4
LED
LD5
LED
LD6
LED
LD7
LED
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA7
PA4
PA5
PA6
Prior to creating a new project, it is necessary to do the following:
Step 1: Install the compiler
Install mikroC PRO for ARM
®
from the
Product DVD
or download it
from the MikroElektronika website:
http://www.mikroe.com/mikroc/arm/
Step 2: Start up the compiler
Double click on the compiler icon in the Start menu, or on your
desktop to Start up mikroC PRO for ARM
®
. The mikroC PRO for ARM
®
IDE (Integrated Development Environment) will appear on the
screen. Now you are ready to start creating a new project.
Page 5
PA7
PA3