You are on page 1of 6

METU NORTHERN CYPRUS CAMPUS

Introduction to Microprocessors &


Embedded Systems Development
EEE 347/CNG 336 LABORATORIES

Spring 2020

1
LABORATORY RULES & INSTRUCTIONS
Lab Grading:
• Your lab grade will contribute 20% to your course grade. You should however get a minimum
70/100 from the laboratory to pass EEE-347/CNG-336.
• Each of the Labs 1 - 5 will be done in a team of two, will contribute 14% of your overall lab grade,
and 2.8% of your overall course grade.
• The final lab (to be held during the finals week) will be done individually, will contribute 30% of
your overall lab grade, and 6% of your overall course grade. Each student will be provided with
an experiment to conduct in the laboratory for the final lab, and answer questions.
Partial grades for each lab will tentatively be distributed as follows:
Quizzes 10%
Reports and preliminary works 30%
Laboratory performance 60%
Preliminary Work:
Students are not permitted to perform an experiment without doing the preliminary work before coming
to the laboratory. It is not allowed to do the preliminary work at the laboratory during the experiment.
Students who do not have complete preliminary work with them at the beginning of the laboratory
session cannot attend the lab. No “make-up” is given in this case.

Quizzes:
There may be a quiz before each laboratory session, which will start promptly at the beginning of the lab.
Students who miss the quiz cannot attend the lab. No “make-up” is given in this case. Students
have to be at the lab promptly on time for the quiz.

Report:
A report about the experiment should be prepared during the experiment and submitted to the assistant
before leaving the laboratory. Each group will submit one report including:
- name of the experiment and students
- name of the assistant and date
- the objective of the experiment
- graphical and/or tabular measurements results
- analytical comparison of the results with the expectations in preliminary work
- conclusions

The report should be written on A4 white paper in a neat and tidy manner. The graphs should be plotted
on commercial A4 graph paper. The report should be submitted immediately after the laboratory session;
any late reports will not be accepted.

Attendance:
• Students who miss the lab 2 times without an excuse get zero as the laboratory portion of the course
grade. Only the following excuses are valid for taking a lab make-up:
1. Health Make-up: Having a health report from METU Medical Center.
2. Exam Make-up: Having an exam coinciding with the time of the laboratory session. The student
needs to notify the instructor in advance if this is the case.

Academic Honesty:
• Plagiarism is a form of cheating as is using someone else’s written word with minor changes and no
attribution. If you are caught cheating, you will, at the very least, receive a zero for the whole
experiment. Disciplinary action may also be taken against you.

Other:
• No food or drink in the lab.

2
EXPERIMENT #1: INTRODUCTION TO
MICROPROCESSORS/EMBEDDED SYSTEMS LABORATORY
1.1 OBJECTIVE
The purpose of the first laboratory exercise is getting familiar with the development environment you
will use throughout the semester in order to apply course learnings. You will experiment with writing and
executing a short assembly code segment to move data to and from the memory, and microcontroller
digital I/O ports. You will debug and simulate your code segment before your scheduled laboratory
session using Atmel Studio Integrated Development Environment (IDE) for AVR. You will then use
Proteus design suite to design and simulate your full system including the AVR microcontroller running
your code, peripheral devices, and interconnects.

After you arrive to your scheduled laboratory session with completed preliminary work, you will utilize
UNI-DS6 development system, hosting a mikroBoard for AVR 64-pin, in order to prototype and test your
design using AVRFLASH software interface for programming AVR Flash ROM. You will demonstrate
code simulations, system simulations, and prototype tests to your lab instructors, and answer any
questions on your work. A tutorial, called “Introduction to EEE-347/CNG-336 Laboratory”, will be provided
by the assistants in a prior lab or recitation to run through the tools you will use throughout this semester
to design, simulate, prototype, and test various microcontroller based systems.

1.2 PRELIMINARY WORK


1.2.1 Read through the tutorial document “Introduction to EEE-347/CNG336 Laboratory”.
1.2.2 a) The following is an ‘almost complete’ program, except it does not have a comments column.
Create a text file with this source code, add a comments column to explain, in at most 5
or 6 words, the function of each command line. Follow the correct syntax. Use the
instruction set summary at the end of ATmega128 datasheet.
;
; This is a simple ATmega128 assembly program that loads the
; values of switches connected to PORTA and PORTB to memory
; addresses $100 and $101 respectively, adds the two numbers
; and stores the resulting sum in the memory location at address
; $102. If there is an overflow, the content of address $103 is
; set to $FF, else content of address $103 is cleared. Contents
; of $102 and $103 are displayed on LEDs connected to PORTC and
; PORTD respectively.

; Code
.INCLUDE "m128def.inc"
.EQU ZEROS = 0x00
.EQU ONES = 0xFF
.EQU MEMNUM1 = 0x100
.EQU MEMNUM2 = 0x101
.EQU MEMSUM = 0x102
.EQU MEMOVF = 0x103

.CSEG
.ORG 0x0050
ldi r16, ZEROS
out ddra, r16
out ddrb, r16
ldi r17, ONES

3
out ddrc, r17
out ddrd, r17
capture: in r18, pina
sts MEMNUM1, r18
in r19, pinb
sts MEMNUM2, r19
add r18, r19
brvc no_ovrflw
ovrflw: com r16
no_ovrflw: sts MEMSUM, r18
out portc, r18
sts MEMOVF, r16
out portd, r16
ldi r16, ZEROS
jmp capture
b) Use AtmelStudio to create lab1_122_AtmelStudio project. Debug your code, entering input
(port) pin values through the I/O window, and making sure that registers, memory locations,
overflow status bit, and output (port) pin values are correct. Take a screen capture (PrtScr)
of two different results and include in your report, one with inputs at PORTA and PORTB
that cause an overflow, and one with inputs that do not cause an overflow. For example,
you may organize the relevant state of your machine to show in your screen capture as follows
(making sure all your scree captures are readable and properly commented upon):

Which lines in the code do not affect the machine state at all?

c) Use Proteus to create lab1_122_Proteus project. Instantiate ATMEGA128 microcontroller, and


as many DIPSW_8 (8-bit dip switch), LED-BIRG (green led), 4k7 (4.7 kΩ resistor), and RX8
(pack of 8 resistors) components as you need in order to design the full system described in
previous sections, and wire the ports for parallel I/O as in UNI-DS6 development board. Load
your debugged code from the previous section to the microcontroller in Proteus, and run the
same two cases as in 1.2.2(b) to demonstrate that the LEDs in your system respond correctly
to the inputs you provide through the switches. Take two screen captures (PrtScr) to show
your system design, and simulated demonstration of correct operation with and without
overflow. Instantiate voltage and current “probes” on the microcontroller output port wires in

4
order to measure voltage and current levels during the simulations. What are the voltage and
current levels at the output pins of the microcontroller when the signal corresponds to logic ‘0’
and ‘1’? Measure the voltage drop across an LED when it is ON? What is this drop when LED
is OFF?
1.2.3 What is the difference between RAM and ROM? Why is there a need for both a Flash Memory
and an EEPROM?
1.2.4 What is the function of the control unit? How does the control unit get the instruction that it must
execute? How does it know the number of bytes in an instruction?
1.2.5 Submit your answers to 1.2.2-1.2.4 at the beginning of the lab as part of the preliminary lab
report.
Bring your AtmelStudio project directory from 1.2.2(b), including the .asm file, to the
laboratory with you in a USB memory stick in order to demonstrate your AtmelStudio
simulations to the lab assistant, and answer any questions.
Bring your Proteus project directory from 1.2.2(c) to the laboratory with you in a USB
memory stick in order to demonstrate your Proteus simulations to the lab assistant, and
answer any questions.

1.3 EXPERIMENTAL WORK

1.3.1 Experimental Setup

Verify to make sure your workbench has all of the following items:
- A Personal Computer (PC) used as a host terminal
- UNI-DS6 Development Board with a socketed mikroBoard for AVR 64-pin
- UNI-DS6 power adapter
- USB Cable for UNI-DS6 mikroBoard to PC connection
- A CADET used to build external circuits (may use in some of your future labs)

1.3.2 System Startup

Please follow the instructions below in order to start the system for your experiments:
1) Turn on the PC.
2) On the desktop, you’ll see icons for AtmelStudio7, Proteus 8, and AVRFLASH.
3) Make sure that the USB cable connects the computer and the UNI-DS6 board.
4) Make sure the power adapter is connected to UNI-DS6 power plug (on the upper left side of
the board). Your mikroBoard card will be powered by the board, so the “STANDALONE”
jumper J1 on the mikroBoard should not be shorted. “VOLTAGE SUPPLY SELECTION”
jumper J16 on the upper left should be set for 5 V operation.

1.3.3 In addition to submitting your preminary work, you are required to make 3 demonstrations to the
lab instructor, as described below. If asked to run your experiments with new conditions, please
comply with the instructions to fully demonstrate your competence of the lab material.

i) Open AtmelStudio7, and enter the annotated assembly program from Preliminary Work
Section 1.2.2(a) to a text editor, or load it from a flash memory connected to the USB of the
terminal. Build and run your code in debug mode (step by step) using the input conditions
(vectors) provided by the TA while monitoring the microcontroller state through the windows
described in the preliminary work.
When you are ready, do your first demo, showing and describing to your TA how the
microcontroller state (registers, status bits, memory, ports) get affected by each line
in the code.

5
ii) Open Proteus, and load up your project from preliminary work. Simulate your system model
using the input conditions provided by the TA.
When you are ready, do your second demo, showing and describing to your TA how
the microcontroller responds to the peripheral inputs/outputs in your design. Answer
any questions.

iii) Make sure the input switch jumpers on the right hand side of UNI-DS6 board (J1-J11) are
configured for pull-up configuration. Turn on the POWER SUPPLY switch on the left side of
UNI-DS6 board. Open AVRFLASH. Load the .hex file generated by the build in section
1.3.3(i), and write to ATmega128 program memory through the programmer on AVR
mikroBoard. Your AVR ports are connected to both push-buttons and DIP-switches. As long
as your UNI-DS6 port configuration jumpers are set correctly, you should be able to provide
your inputs to the AVR ports through either push-buttons or DIP-switches.
When you are ready, do your third demo, showing and describing to your TA how the
final system operates. Remember to demonstrate the system response for both
overflow and no-overflow cases.
Note: The program LED at the mikroBoard will turn on and off during the programming of the
microcontroller. If you do not see any LEDs flashing after you hit the “write” button in
AVRFLASH interface window, there may be a communication problem between your terminal
and the AVR mikroBoard. Check with your TA to ensure the correct (USB18F Firmware v1.20)
driver is installed for the operating system at your terminal.

You might also like