0% found this document useful (0 votes)
48 views11 pages

MP Lab1 032

This document summarizes an introductory lab on microcontroller development tools and software. It introduces Arduino and AVR Studio for writing code, and Proteus for simulation. The lab tasks cover compiling and running a simple blinking LED program in Arduino and AVR Studio, selecting a microcontroller in Proteus, and generating a Fibonacci series output on a port using code and simulation. In conclusion, the student discusses learning about using AVR for writing C code and Proteus for simulation and connecting to AVR code through a HEX file.

Uploaded by

EARNING POINT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views11 pages

MP Lab1 032

This document summarizes an introductory lab on microcontroller development tools and software. It introduces Arduino and AVR Studio for writing code, and Proteus for simulation. The lab tasks cover compiling and running a simple blinking LED program in Arduino and AVR Studio, selecting a microcontroller in Proteus, and generating a Fibonacci series output on a port using code and simulation. In conclusion, the student discusses learning about using AVR for writing C code and Proteus for simulation and connecting to AVR code through a HEX file.

Uploaded by

EARNING POINT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

EEE342 Microprocessor Systems & Interfacing

COMSATS University Islamabad (CUI) , Islamabad Campus Page 1


Lab# 12: Interfacing Devices using SPI

Lab # 01

Introduction to Development Tools and LabSoftwares

In-Lab
In-Lab Task 1: Arduino Learning Tutorial

Code:-

Figure 1.5 Compiling a Sketch in Arduino

In This task We Simply Sketch a Light blink program Fusing Arduino Ide.The Code we Took
from examples Which Is stored In the Arduino

COMSATS University Islamabad (CUI) , Islamabad Campus Page 2


Lab# 12: Interfacing Devices using SPI

In-Lab Task 2: AVR Studio Learning Tutorial

Explanation:-
We first time use AVR Microcontroller and found the different Simulation Option
either To Do Code using C language Or By Assembler. First Time There Was
diffuculty To Find The Hex File But Learned And Remembered It.Press F7 button to
build output files of the project including object file and hex file.

C-Code:
/*This code will configure Port B for output and then toggle Port B
pin 3 with a delay of 1000ms*/

#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()

{ // Write your code here

DDRB = 0b11111111; //Configure Port B as Output

while(1) //This loop will run forever {

PORTB = 0b00001000; /*Send 1 on Port B Pin 3,

rest of the pins are zero*/

_delay_ms(1000); //Delay of 1000ms

PORTB = 0b00000000; //Send 0 on Port B Pin 3

_delay_ms(1000); //Delay of 1000ms } }

COMSATS University Islamabad (CUI) , Islamabad Campus Page 3


Lab# 12: Interfacing Devices using SPI

SIMULATION :-

In-Lab Task 3: Atmel Studio Learning Tutorial


Explanation :-

We know Which Controller we will use and In our next labs On which
controller We will Performs Task Also We Specify That The controller
In Arduino Is Atmega328P Every Time We will select This when We
Rum AVR controller Foe Our Code

SIMULATIONS OR Method :

COMSATS University Islamabad (CUI) , Islamabad Campus Page 4


Lab# 12: Interfacing Devices using SPI

Figure 1.10 – How to create new project using Microchip Studio installed in Lab

Figure 1.11 – Compiler selection and Project name description with location
1. In the Device Selection window, select ATmega328P. Click OK to create the
project as shown in figure 1.12.

Figure 1.12 – AVR microcontroller Selection

In-Lab Task 4- Proteus Introductory Learning Tutorial


Simply open New Project and Give save Path then We Will come to this page

COMSATS University Islamabad (CUI) , Islamabad Campus Page 5


Lab# 12: Interfacing Devices using SPI

1..14: Proteus ISIS overview of window

We Will Click On Library And Will search things Which we want

Figure 1.15: Pick Devices for circuit diagram

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


i. ATmega328 Microcontroller
ii. Animated LED
iii. 470 ohms resistor
After Getting these All Simply Connect them Amd Upload Hex File

COMSATS University Islamabad (CUI) , Islamabad Campus Page 6


Lab# 12: Interfacing Devices using SPI

Figure 1.16: Circuit Diagram for In-Lab Task 3

In Lab Task 4:
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, ….. 100).
Explanation :-
We simply write code in which we get Output On port B which is fabnonacci series
Number We display.
CODE:

COMSATS University Islamabad (CUI) , Islamabad Campus Page 7


Lab# 12: Interfacing Devices using SPI

Proteous work :

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.
In This code there were error Given in it we Removed Them ans Simply Run the Pro

COMSATS University Islamabad (CUI) , Islamabad Campus Page 8


Lab# 12: Interfacing Devices using SPI

c. The following code is written to generate fibonacci series output at PortB which
is given as (0, 1, 2, 3, 5, 8, .

Proteus Simulation :-

COMSATS University Islamabad (CUI) , Islamabad Campus Page 9


Lab# 12: Interfacing Devices using SPI

As We Give Input in code Same We Can see Turn On the lights In Protesus

Critical Analysis / Conclusion


(By Student about Learning from the Lab)

This Lab WS Our Introductory Lab And We Little Bit performed Simple tasks
The First Software Is AVR Microcontroller which is easy To use if we Know C
language Simply We can Make logics And Can Type Code By self AVR we get
A lot Options Of Different Micro Controller Chips but Our Required is
Atmega328P In which We Perform Our Next labs. The Second one Is Proteus
We already Used It has library And Which thing We Need We simply Search in
it E.g. We Need Controller We search Astmega328P and Resistor and connect
Them Through Wire But New Thing Is HEX File Which Connect AVR With
PROTEUS SIMULATIONS IN background We Change AVR code it Will
Affect On Proteus Simulations

Lab Assessment

Pre Lab /1

COMSATS University Islamabad (CUI) , Islamabad Campus Page 10


Lab# 12: Interfacing Devices using SPI

In Lab /5
Post Lab Data /4
Analysis
Data /4 /4
/10
Presentation
Writing Style /4

COMSATS University Islamabad (CUI) , Islamabad Campus Page 11

You might also like