Lab 01
Lab 01
EEE-342
Lab Report 01
Class BEE-5C
Objectives:
• Learn to use software development tools such as Arduino, Integrated Development
Environment (IDE) (Atmel Studio, AVR Studio), Compiler (WinAVR), and Simulator
(Proteus) for the AVR ATmega 328P microcontroller.
• Learn to program Arduino and ATmega328P.
Softwares Used:
• Arduino
• Atmel Studio (Version 7)
• AVR Studio (Version 4)
• Proteus ISIS
• WinAVR (Version 2010)
AVR Studio:
AVR Studio is an Integrated Development Environment (IDE) used to develop projects
(software part) for AVR microcontrollers. This IDE consists of a project management tool,
source filer editor, assembler and front-end for C/C++ programming, a debugger and a
hardware (MCU registers) Simulator. With AVR Studio, you can develop code in C as well as
in Assembly Language. Both approaches are different from each other. Each has its own merits
as you will learn during the coursework.
Atmel Studio:
Atmel Studio 7 is the integrated development platform (IDP) for developing and debugging
Atmel Atmel AVR microcontroller (MCU) applications. Atmel Studio 7 supports all AVR
MCUs. It gives you a seamless and easy-to-use environment to write, build and debug your
applications written in C/C++ or assembly code. It also connects seamlessly to Atmel
debuggers and development kits.
WinAVR:
WinAVR is a suite of executable, open source software development tools for the Atmel AVR
series of microprocessors hosted on the Windows platform. It includes the GNU GCC compiler
for C and C++. You will install this software (release 2010) on your PC/Laptop and it will be
used to compile your C/C++ code for the AVR microcontroller. IDEs such as AVR Studio will
automatically detect and use WinAVR installation and you will not need to run this software
yourself.
Proteus:
The Proteus Design Suite is a complete software solution for circuit simulation and PCB
design.Proteus can simulate electric/electronic and microcontroller based circuits. It supports
number of microcontrollers available in the market.
ATmega 328p:
The Atmel AVR ATmega328P is a low-power 8-bit microcontroller architecture.It has 131
Powerful Instructions. Most of them require single clock cycle for execution. It has 32K bytes
of In-System Programmable Flash Program memory with Read-While-Write capabilities, 1K
bytes EEPROM, 2K bytes SRAM, 23 general purpose I/O pins and 32 general purpose working
registers.
• DDRx (Data Direction Register) - Sets the direction of each pin as input or output.
• PORTx - Used to output/write values on a Port.
• PINx - Used to input/ read values from a Port.
Where x is the port B, C or D. All of these registers are 8-bit registers. Figure 1.1 shows the
three registers associated with Port B.
In-Lab Tasks:
Task 1:
Arduino Learning Tutorial
1. Launch Arduino IDE.
2. Some built-in examples are included in Arduino software. Click on the toolbar menu:
File > Examples > Basics > Blink. This will turn an LED on Arduino board on and off
with some delay.
3. Compile the sketch. After successful compilation, the code can be uploaded to the
Arduino board.
Figure 1.3 shows a basic Arduino sketch.
Task 2:
AVR Studio Learning Tutorial
1.Launch AVR Studio either by start menu or by selecting desktop icon. Then Select Project
Wizard form menu bar and Select New Project as shown in Figure 1.4
2. After selecting New Project, two options will be displayed (AVR Assembler and AVR
GCC). AVR Assembler is selected for the assembly code and AVR GCC is selected to
compile C-code. In this tutorial, we will use C-code so select AVR GCC. Write project
name (lab1 for this tutorial) and select the path directory path to save files for this new
project (Select desktop and lab1 as folder name) and Click Next (Figure 1.5).
Figure 1.5: Compiler selection and Project name description with location
3. In the next menu, select AVR Simulator in debug platform and ATmega328P in device
menu. After selection click finish as shown in Figure 1.6.
C-Code:
Press F7 button to build output files of the project including object file and hex file.
Task 3:
Atmel Studio Learning Tutorial
1-Launch Atmel Studio either by start menu or by selecting desktop icon. From start page
new projects can be created and recently used projects can be opened. The Start page can
also be accessed from View → Start Page, or Alt V G. Click on new project as shown in
Figure 1.8.
Figure 1.8: How to create new project using Atmel Studio installed in Lab
1. After selecting New Project, the project wizard will appear. AVR Assembler is selected
for the assembly code and C/C++ is selected to compile C-code. In this tutorial, we will
use C-code so select C/C++ and then select GCC C Executable Project. Write project
name, select the path directory path to save files for this new project and Click ok
(Figure 1.9).
Figure 1.9: Compiler selection and Project name description with location
2- In the Device Selection window, select ATmega328P. Click OK to create the project as
shown in Figure 1.10.
Figure 1.10: AVR Microcontroller Selection
3.Layout shown in figure 1.11 will appear on the screen. Layout will consist of source code
window and message window. Write a code given in Task 1 in the source window.
1. Launch Proteus from start menu or by desktop icon. Proteus layout shown below will
appear on the screen as shown in Figure 1.12. There is a root sheet to draw circuit. The
device window will initially be empty and you need to pick components from library.
Proteus component library is equipped with lots of components and ICs including
microcontrollers. To pick necessary components required for circuit, click on small P
in device window.
2. After Clicking Pick devices menu as in figure 1.13 will appear on the screen. There is a
keyword prompt which can refine your search. Write ATmega328P in keyword prompt and
result window will display components having keyword of ATmega328P. Double click
ATmega328P component in result window to add it to device list.
Figure 1.13: Pick Devices for circuit diagram
5. simply double click the required component. An edit component menu will appear for
that particular component where you can change the characteristic properties of that
component.
6. You also need to load your required program into the microcontroller memory as shown
in Figure 1.15. Program is loaded into microcontroller memory through hex file.
Double click microcontroller, edit menu will have prompt for load program. Select the
hex file generated from Atmel Studio tutorial. This hex (Lab1.hex) file can be found in
the Lab1 directory you created on desktop for the Atmel Studio tutorial.
7. The default frequency of ATmega328p is 1MHz. To change it to 16MHz, we will
provide external clock source of 16MHz. Select CKSEL Fuses (0000) Ext. Clock, In
Clock Frequency, write 16MHz and select CLKDIV8 fuse to be unprogrammed.
Code:
Conclusion:
At end, in this lab we see some basic use of software’s like Arduino IDE, AVR studio, ATMEL
studio and Proteus. ATMEL and AVR Studio are integrated development environments (IDEs)
used for programming and developing software for AVR microcontrollers. While Proteus
software is used for electronic circuit design, simulation, and PCB (Printed Circuit Board)
layout design. In our first task, we just copy the code, compile it and upload it on Arduino IDE
to see the blinking light on Arduino Nano. In second task, we create a new project file in AVR
studio, copy and paste the code and press F7 button to build output files of the project including
object file and hex file. In the third task, we create a new project file in ATMEL studio, Press F7
button to build output files of the project including object file and hex file. We try it out with the
code given in task2. In task four-part a, we use proteus to make a simple circuit of blinking
LED with some delay time. In task four-part b, we debug the given code and generate Fibonacci
series output at PortB which is given as (0, 1, 2, 3, 5, 8, 13, 21, 34, 55).
-------------------------------------------------------------------------------------------------------------------