You are on page 1of 7

COMSATS UNIVERSITY

MICROPROCESSOR SYSTEMS & INTERFACING


EEE-342

Lab # 01 Introduction to Development Tools and Lab Software

Name

Registration
Number

Instructor’s Name MA’AM ASMA RAMAY

Lab # 01 Introduction to Development Tools and Lab Software


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

Get the following software installers from MP/VLSI lab and install them in your laptops. The
same software will be available in the Lab PCs.
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 these registers are 8-bit registers. Figure 1.1 shows the three
registers associated with Port B.
Pin configuration of ATmega 328P can be seen in Figure 1.1.

IN LAB-TASKS:

Task 1: Arduino Learning Tutorial: 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. Compile the
sketch. After successful compilation, the code can be uploaded to the Arduino
board.
Task 2: AVR Studio Learning Tutorial: Launch AVR Studio and Select Project Wizard
form menu bar and Select New Project and follow the instructions given in lab manual.
Then write down the code below in source window.
In this we learned about AVR Studio step by step, steps given in Lab Manual. And we run a
given code in AVR studio. After running of code we tested the code in Protues by running the
Atmega328p.

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:
//This code will generate Fibonacci series.
#include /*This header file includes the appropriate I/O definitions for the device */
#define F_CPU 16000000UL //XTAL Frequency =16MHz
#include /*This header file is required for generating delays*/
int main(void)
{ DDRB = 0b11111111 //Configure Port B as Output
int t1 = 1, t2 = 1, nextTerm = 0, i = 1;
while (i < 10)
{ PORTB = nextTerm; //Generate fibanocci series
nextTerm = t1 - t2;
t1 = t2;
t2 = nextTerm;
i = i + 1; }
while (1)
{
}
return 0; }

THE CORRECTED CODE:


//This code will generate fibanocci series.
#include <avr\io.h> /*This header file includes the apropriate
I/O definitions for the device */
#define F_CPU 16000000UL //XTAL Frequency =16MHz
#include <util/delay.h> /*This header file is required for
generating delays*/
int main(void)
{
DDRB = 0b11111111; //Configure Port B as Output
int t1 = 0, t2 = 1, nextTerm = 0, i = 1;
while (i < 10)
{
PORTB = nextTerm;
//Generate fibanocci series
nextTerm = t1 + t2;
t1 = t2;
t2 = nextTerm;
i = i + 1;
}
while (1)
{
}
return 0;
}

CRITICAL ANALYSIS / CONCLUSION


In this lab we were able to get a brief overview about AVR studio and Proteus. It is clearly
evidential that AVR studio is one of those platforms used to program microcontrollers. We
discussed about the different types of Arduino and its working. Although this was a general
overview which explained how to create project, running the program and to upload it on proteus
we could have done a bit more in this lab such as helping us understanding the limitations of this
software and to debug a problem when the software is not working or when the output files are
not being generated.
TASK 1 OUTCOME: In this task an example code was compiled according to which LED turns
on/off with some delay.
TASK 2 OUTCOME: In this task some errors were removed from the given code.

You might also like