100% found this document useful (1 vote)
65 views15 pages

Lab 01

1. The document describes an introduction lab for development tools and software used with AVR microcontrollers, including Arduino, AVR Studio, Atmel Studio, WinAVR, and Proteus. 2. The objectives are to learn how to use these software tools to program Arduino and ATmega328P microcontrollers. Softwares like Arduino IDE, AVR Studio, Atmel Studio, WinAVR compiler, and Proteus simulator are introduced. 3. In-lab tasks involve learning tutorials for each software - programming a basic blink sketch on Arduino, writing and compiling a simple C code program in AVR Studio and Atmel Studio, and simulating a microcontroller circuit in

Uploaded by

daniyal2k23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
100% found this document useful (1 vote)
65 views15 pages

Lab 01

1. The document describes an introduction lab for development tools and software used with AVR microcontrollers, including Arduino, AVR Studio, Atmel Studio, WinAVR, and Proteus. 2. The objectives are to learn how to use these software tools to program Arduino and ATmega328P microcontrollers. Softwares like Arduino IDE, AVR Studio, Atmel Studio, WinAVR compiler, and Proteus simulator are introduced. 3. In-lab tasks involve learning tutorials for each software - programming a basic blink sketch on Arduino, writing and compiling a simple C code program in AVR Studio and Atmel Studio, and simulating a microcontroller circuit in

Uploaded by

daniyal2k23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 15

Microprocessor Systems & Interfacing

EEE-342
Lab Report 01

Name Muhammad Daniyal Akram

Registration Number FA21-BEE-233

Class BEE-5C

Instructor’s Name Dr. Sikender Gul


Introduction to Development Tools and Lab Softwares

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)

Pre Lab Task:


Arduino:
Arduino is an open-source platform used for building electronics projects. It consists of both a
physical programmable circuit board and an IDE (Integrated Development Environment) that
runs on your computer. Most Arduino boards consist of an Atmel 8-bit AVR microcontroller
with varying amounts of flash memory, pins and features. Arduino is programmed using
the Arduino Software (IDE) which is a cross-platform application for windows, macOS and
Linux. It is connected to a PC via USB cable to upload computer code to the physical board.
This also provides power to the board, as indicated by a LED.

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.

ATmega 328P Peripheral Features:

• 3 flexible Timer/Counters with compare modes


• Six PWM Channels
• Internal and External Interrupts
• A serial programmable USART
• Two Master/Slave SPI Serial Interface
• 8 channel 10-bit ADC

ATmega328P Pin configuration:


The 23 digital I/O pins are grouped into 3 ports named as Port B, C and D. Port B and D have 8
pins each whereas Port C has 7 pins. Pin 4 and 6 are required to connect with +ve (VCC) and
pin 3, 5 and 21 need to connect with ground (GND).Pin 18 is the supply voltage pin for the
A/D Converter. Pin 20 is the analog reference pin for the A/D Converter.
Each of the AVR Digital I/O port i.e Port B, Port C and Port D are associated with three I/O
registers. These resigters are:

• 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.

Figure 1.1 Registers Associated with Port B

Pin configuration of ATmega 328P can be seen in Figure 1.1.


Figure1.2 Pin Configuration of ATmega328p

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

Figure 1.4: Creating a new project in AVR Studio 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.

Figure 1.6: AVR microcontroller Selection


4. Layout shown in Figure 1.7 will appear on the screen. Layout will consist of source
Window, I/O window, message window and I/O toolbar.
Figure 1.7: AVR Studio platform section wise overview

5. Write down the code below in source window.

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.

Figure 1.11: AVR Studio platform section wise overview


4. Press F7 button to build output files of the project including object file and hex file.
Task 4 (a):
Proteus Introductory Learning Tutorial
To learn basics about Proteus, we will simulate a microcontroller based circuit in Proteus. We
will use the same program for microcontroller which we simulated in AVR Tutorial.

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.

Figure 1.12: Proteus ISIS overview of 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

3. As described in step 2 add following components needed for this tutorial


i. ATmega328 Microcontroller
ii. Animated LED
iii. 470 ohms resistor
4. To add any component on root sheet, simply select that component from device window
and click anywhere in the root sheet to place that component. To draw wire connection
between two pins of any components, simply move mouse cursor to the tip of the pin
and click. Then click on tip of the other pin you wanted to connect. Draw a circuit
shown in figure 1.14 on Proteus root sheet by using components indicated above.

Figure 1.14: Circuit Diagram for In-Lab Task 3


On the left side of Proteus layout, different modes can be selected. To add ground terminal
to the circuit, click terminal mode from buttons on left side of screen and then select ground
terminal. You can change characteristic properties of any component. To change,

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.

Figure 1.15: Edit component menu


8. Now run the simulation from the bottom of Root Sheet and show result to your lab
instructor.
Task 4 (b):
a. The following code is written to generate fibonacci series output at PortB
which is given as (0, 1, 2, 3, 5, 8, 13, 21, 34, 55).
b. Build the following code in AVR Studio or Atmel Studio. Read the error
messages, identify and correct any syntax errors and rebuild the solution.
c. Use Debugging mode of AVR Studio or Atmel Studio to debug and
correct the code to get the desired output. In debug mode, open watch
window to check the value of the variables.

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).
-------------------------------------------------------------------------------------------------------------------

You might also like