Microprocessor and intergacing Lab report 02, Study Guides, Projects, Research of Microprocessors

This is the Lab report 2 of Microprocessor and interfacing of Comsats University Islamabab.

Typology: Study Guides, Projects, Research

2022/2023

Uploaded on 05/08/2023

arslan-bin-shabeer
arslan-bin-shabeer 🇵🇰

2 documents

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Microprocessor Systems & Interfacing
(EEE-342)
Lab Report # 02
Name Arslan Shabeer
Registration Number FA20-BEE-033
Class BEE-5A
Instructor’s Name Sir Sikendar Gull SB
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Microprocessor and intergacing Lab report 02 and more Study Guides, Projects, Research Microprocessors in PDF only on Docsity!

Microprocessor Systems & Interfacing

(EEE-342)

Lab Report # 02

Name Arslan Shabeer

Registration Number FA20-BEE-

Class BEE-5A

Instructor’s Name

Sir Sikendar Gull SB

Lab # 02 Introduction to AVR Microcontroller Hardware
Circuitry and Digital I/O Ports
Introduction:

This lab is about what type of circuit are used to make the microcontroller. Learn to program (download code to program memory of) a microcontroller using Arduino board. To understand and use digital I/O ports of AVR microcontroller. This lab is about what type of ARDUINO we use in lab and their specification.

In lab Task 1:
In this task we were given to write this Code on the AVR studio and
then Stimulate it on the Proteous.
Here is the code and Simulation Diagram of this Code
Code:
#include <avr/io.h>
#define F_CPU 16000000UL
#include <util/delay.h>
int main()
DDRB=0b00000000;
while(1)
PORTB = 0b00000000;
_delay_ms (1000);
PORTB = 0b00000000;
_delay_ms (1000);

.INCLUDE <M328PDEF.INC> /This header file tells the assembler to include the m328Pdef.inc file which you downloaded / LDI R18, 0XFF / R18=0XFF/ OUT DDRB, R18 /* DDRB=R18/ LDI R21, 3 / R21=3 / LOOP: LDI R16, 10 / R16=10 / LDI R20, 0 / R20=0 / AGAIN: ADD R20, R21 / R20=R20+R21 / OUT PORTB, R20 / PORTB=R20 / DEC R16 / R16=R16-1 / BRNE AGAIN / It will run the Fuction again & again until the value of R16 comes to zero as we are givinga Decrement in R16 / RJMP LOOP / and when will it come to zero this Jumber function take it again to "LOOP"*/ Figure 2.3: Proteous Simulation of task 2 Task 3:

(To be assigned by Lab instructor_ Switches are connected to one port of
ATmega328p for input and LEDs are connected to another port for output.
Using these, perform a task assigned by your lab instructor. Students
should write the code for given task, simulate it on proteus and then
implement it on hardware.

#include <avr/io.h> #define F_CPU 16000000UL #include <util/delay.h> int main() { DDRB = 0xff; DDRD = 0x00; PORTD = 0x00; while(1) { char x; x = PIND; if (x==0x00) { PORTB = 0x00; } else if (x == 0x01) { PORTB = 0x01; } else if (x == 0x02) { PORTB = 0x02; } else if (x == 0x04) { PORTB = 0x04; } else if (x == 0x08) { PORTB = 0x08; } else if (x == 0x10) { PORTB = 0x10; } else if (x == 0x20) { PORTB = 0x20; } else if (x == 0x03) { PORTB = 0x03; } else if (x == 0x05) { PORTB = 0x05; } else if (x == 0x3F) { PORTB = 0x3F; } _delay_ms(10); } }

In the reverse Code we have to turn on the Opposite leds of the Given input if the opposite port e.g., we turn the first switch ON then instead of first led all LED will turn ON. #include <avr/io.h> #define F_CPU 16000000UL #include <util/delay.h> int main() { DDRB = 0xff; DDRD = 0x00; PORTD = 0x00; while(1) { char x; x = PIND; if (x==0x00) { PORTB = 0xFF; } else if (x == 0x01) { PORTB = 0xFE; } else if (x == 0x02) { PORTB = 0xFD; } else if (x == 0x04) { PORTB = 0xFB; } else if (x == 0x08) { PORTB = 0xF7; } else if (x == 0x03) { PORTB = 0xFC; } else if (x == 0x05) { PORTB = 0xFA; } else if (x == 0x3F) { PORTB = 0x00; } _delay_ms(10); } }

Figure 2.5: Proteous Simulation of task 3(the opposite Leds is/are turning “ON” on switching on the Pin of opposite PORT)

Figure 2.6: Proteous Simulation of Post Task(the Same Led is/are turning “ON” on switching on the Pin of opposite PORT)

Critical Analysis:

In this lab we learn and understand the minimal circuit required to start using a microcontroller. We got introduction about microcontroller hardware Arduino UNO. We studied about its circuit diagram and its ports, also we burnt some hex files on it to analyze them on hardware using microcontroller. We learn how to program a memory of a microcontroller using Arduino board. We also understand and use digital I/O ports of AVR microcontroller. In 1st^ task the code is simple just to make a LED to Blink. In 2nd^ in Lab task, we just coded a different thing that we use a switch to control our input and show the same form of input on output. And we also have to repeat the Code but this with inverse output. In post lab I repeated the 2nd^ task but this time by using Arduino on Proteous Simulation. Also, we learn the basic port connection this lab to the hardware on simulation like as on Arduino UNO/NANO. Simulation is very important before performing any hardware task, it gives you the idea how it will be designed. Performing on hardware will cost you very high. That’s why we used the simulation method before the implementation of our actual hardware.