Sie sind auf Seite 1von 9

ANADOLU UNIVERSITY

DEPARTMENT OF
ELECTRICAL AND ELECTRONICS ENGINEERING
EEM 489 Microprocessors II
Fall, 2014-2015
Lab 3 Report

Date: 31.10.2014
EZG TETK 36151392336
Mahmut Ferit YILDIZ 53206053790
Alper KAPITAI 15529041298

1.)Purpose
The purpose of Lab 4 is to learn minimally intrusive debugging
skills and some software skills. One of these skills is called dump that
allows the program to capture strategic information which will will be
viewed at a some definite later time. The other one of these skills is
heartbeat . Heartbeat is the visual means to see that the written
program is still running or not. The indexed adressing is the one of the
software skills that examined in the lab 4. In addition , array data
structures, phase lock loop initialization, and usage of systick timer are the
other software skills that learned in the lab 4.
The index addressing was used in this lab for accessing the arrays
using pointers (datapt and timept). The databuffer array was used to
keep the situaion of the led(portE data) whether it is 1 or 0 and timebuffer
array was used to keep the value of the counter . To calculate the counter
value, the systick timer was used. In this lab system should work on the
80Mhz frequency . The phase lock loop initialization was used for
arranging the crystal to work on 80 Mhz frequency.

2.Procedure
First of all, the program code which was written at Lab2 was
modified for Lab3 requirements.At the software, the initialization part was
adjusted for port E. So, PE0 pin was configurated as input and and the
other pins were output. After that, the led situation was done as on. At the
loop label, the delay subroutine was defined as 62 ms approximately. The
clock cycles was calculated about 240000 and observed on the logic
analyzer. Then, according to switch situation, led will be on or toggle. The
program goes back to loop point and keep doing this permanently.
After the modification on the software,circuit drawed on PCBArtist
program. Then ,hardware circuit was set up and before connecting the
switch to the microcomputer ,.After that, the program code was loaded to
kit. Led status was observed for different switch positions. Some
measurements were performed for control the materials.
Flow Chart of the whole program and Pseudo Code of the system

Pseudo Code of the system;


Main Turn on the clock for Port E
Set the Port E direction register so
PE4 is an input and
PE2 is an output
Enable the PE4 and PE2 bits in the Port E DEN register
Set bit 4 in Port E PUR register so it will run on the real board
Set PE2 so the LED is ON
loop Delay about 1ms
Read the switch and test if the switch is pressed
If PE4=0 (the switch is pressed),
toggle PE2 (flip bit from 0 to 1, or from 1 to 0)
If PE4=1 (the switch is not pressed),
set PE2, so LED is ON
Go to loop

3.Questions
3.1) Circuit diagram , using PCBArtist

3.2).The Screenshots
Switch is not pressed, led is on ;

Switch is pressed, led is toggling;

While the switch is pressed and led is toggling, suddenly switch is not pressed
and led will be on;

3.3.) Switch Measurements Table


Parameter

Value

Resistance of the
10k resistor, R1

Units

Conditions

ohms

with power off and


disconnected from circuit
(measured with
ohmmeter)
Powered
(measured with
voltmeter)
Powered, but
with switch not pressed
(measured with
voltmeter)
Powered, but switch not
pressed
I=VPE0/R1 (calculated
and
measured with an
ammeter)
Powered and
with switch pressed
(measured with
voltmeter)
Powered and switch
pressed
I=VPE0/R1 (calculated
and
measured with an
ammeter)

9.7 k
Supply Voltage,
V+3.3

volts
3.27

Input Voltage,
VPE0

Resistor current

volts
0.3

Calculated: 0.03
Measured: 0.01

Input Voltage,
VPE0

Resistor current

mA

volts
3.28

Calculated: 0.338
Measured: 0.307

mA

3.4.)Led Measurements Table


Row Parameter

Value

Units

Conditions

Resistance of the
220 ohm resistor, R10

219

ohms

+5 V power supply
V+5

4.98

volts

with power off and


disconnected from circuit
(measured with ohmmeter)
(measured with voltmeter,
notice that the +5V power is
not exactly +5 volts)

1.7

volts

1.86

volts

3.5

volts

TM4C123 Output, VPE1


input to 7406
7406 Output, VkLED k
LED a+, Va+
Bottom side of R10
LED voltage

3.5-1.86=1.64

volts

LED current

Calculated: 6.7
Measured: 6.3

mA

3.28

volts

0.245

volts

2.17

volts

11

TM4C123 Output, VPE1`


input to 7406
7406 Output, VkLED k
LED a+, Va+
Bottom side of R10
LED voltage

1.925

volts

12

LED current

Calculated: 12.0
Measured: 12.2

mA

4
5

9
10

with PE1 = 0
(measured with voltmeter)
with PE1 = 0
(measured with voltmeter)
with PE1 = 0
(measured with voltmeter)
calculated as Va+ - Vkcalculated as (V+5 - Va+)/R10
and
measured with an ammeter
with PE1 = 1
(measured with voltmeter)
with PE1 = 1
(measured with voltmeter)
with PE1 = 1
(measured with voltmeter)
calculated as Va+ - Vkcalculated as (V+5 - Va+)/R10
and
measured with an ammeter

3.5).Assembly Source Code


The source code of the system is at the Appendix.

4.Conclusion
In this lab , the lab3 software program was used with real time delay. The
real time clock estimation using the 24 bit counter is learned. The Crystal
arrangement of 80 Mhz is learned and examined in the pll_init subroutine .
Advanced index addressing and array data structures is learned well.

Hardware implementation;

5.) Appendix
;********************main.s******************
SYSCTL_RCGCGPIO_R
SYSCTL_SCGCGPIO_R
SYSCTL_DCGCGPIO_R

EQU
EQU
EQU

0x400FE608
0x400FE708
0x400FE808

GPIO_PORTE_DATA_R
GPIO_PORTE_DIR_R
GPIO_PORTE_AFSEL_R
GPIO_PORTE_PUR_R
GPIO_PORTE_DEN_R
GPIO_PORTE_AMSEL_R
GPIO_PORTE_PCTL_R

EQU
EQU
EQU
EQU
EQU
EQU
EQU

0x400243FC
0x40024400
0x40024420
0x40024510
0x4002451C
0x40024528
0x4002452C

AREA
THUMB
EXPORT

|.text|, CODE, READONLY, ALIGN=2

Start
Start
;
BL TExaS_Init ; voltmeter, scope on PD3
BL PortE_Init
; initialize input and output pins of Port E
MOV R0, #0x02
; R0 = 0x00000010 (PE1 LED on)
BL PortE_Output
; turn the green LED on
CPSIE I ;TExaS voltmeter, scope runs on interrupts loop
LDR
BL
BL
AND
CMP

R0, =ONEMSEC
delay
PortE_Input
R0, R0, #0x01
R0, #0x01

; R0 = ONEMSEC (delay 62 milisecond)


; delay at least (3*R0) cycles
; read all of the switches on Port E
; R0 == 0x00?

BNE led_on
led_toggle
BL
EOR
BL
B

PortE_Input
R0,R0,#0x02
PortE_Output
loop

led_on
MOV R0, #0x02
BL PortE_Output
B

; else, toggle led


; toggle
; toggle

; R0 = 0x00000010 (PE1 LED on)


; turn the blue LED on

loop

;------------delay-----------; Delay function for testing, which delays about 3*count cycles.
; Input: R0 count
; Output: none
ONESEC
EQU 9333333 ;approximately 1s delay at ~16 MHz clock

ONEMSEC
EQU 240000 ;approximately 1ms delay at ~16 MHz clock
QUARTERSEC
EQU 1333333 ;approximately 0.25s delay at ~16 MHz clock
delay
SUBS R0, R0, #1
; R0 = R0 - 1 (count = count - 1)
BNE delay
; if count (R0) != 0, skip to 'delay'
BX LR
; return
PortE_Init
LDR R1,
LDR R0,
ORR R0,
STR R0,

=SYSCTL_RCGCGPIO_R
[R1]
R0, #0x10
[R1]

NOP
NOP
LDR R1, =GPIO_PORTE_DIR_R
MOV R0,#0xfe
STR R0, [R1]

; 1) activate clock for Port E


; set bit 4 to turn on clock for PE

; allow time for clock to finish


;2) set direction register of PE
;PE1 output, PE0 and others input

LDR R1, =GPIO_PORTE_AFSEL_R


; 3) regular port function+
MOV R0, #0
; 0 means disable alternate function
STR R0, [R1]
LDR R1, =GPIO_PORTE_PCTL_R
MOV R0, #0
STR R0, [R1]
LDR R1, =GPIO_PORTE_DEN_R
MOV R0, #0xFF
STR R0, [R1]

; configure as GPIO
; 0 means configure Port E as GPIO
; 5) enable Port E digital port
; 1 means enable digital I/O

LDR R1, =GPIO_PORTE_AMSEL_R


; disable analog functionality
MOV R0, #0
; 0 means analog is off
STR R0, [R1]
BX LR
PortE_Input
LDR R1, =GPIO_PORTE_DATA_R ; pointer to Port F data
LDR R0, [R1]
; read all of Port F
AND R0,R0,#0x03
; just the PE0 input pin and PE1
output pin
BX LR
; return R0 with inputs
PortE_Output
LDR R1, =GPIO_PORTE_DATA_R ; pointer to Port E data
STR R0, [R1]
; write to PE1
BX LR
ALIGN
; make sure the end of this section is aligned
END
; end of file

Das könnte Ihnen auch gefallen