lab 4 report yildiz_kapitasi

11
ANADOLU UNIVERSITY DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EEM 489 Microprocessors II Fall, 2014-2015 Lab 3 Report Date: 31.10.2014 EZGİ TETİK 36151392336 Mahmut Ferit YILDIZ 53206053790

Upload: mahmut-ferit-yildiz

Post on 16-Jan-2016

11 views

Category:

Documents


0 download

DESCRIPTION

report

TRANSCRIPT

Page 1: Lab 4 Report Yildiz_kapitasi

ANADOLU UNIVERSITY

DEPARTMENT OF

ELECTRICAL AND ELECTRONICS ENGINEERING

EEM 489 Microprocessors II

Fall, 2014-2015

Lab 3 Report

Date: 31.10.2014

EZGİ TETİK 36151392336

Mahmut Ferit YILDIZ 53206053790

Alper KAPITAŞI 15529041298

Page 2: Lab 4 Report Yildiz_kapitasi

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

Page 3: Lab 4 Report Yildiz_kapitasi

Pseudo Code of the system;

Main Turn on the clock for Port ESet the Port E direction register so

PE4 is an input andPE2 is an output

Enable the PE4 and PE2 bits in the Port E DEN registerSet bit 4 in Port E PUR register so it will run on the real boardSet PE2 so the LED is ON

loop Delay about 1msRead the switch and test if the switch is pressedIf 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

Page 4: Lab 4 Report Yildiz_kapitasi

3.2).The Screenshots

Switch is not pressed, led is on ;

Page 5: Lab 4 Report Yildiz_kapitasi

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;

Page 6: Lab 4 Report Yildiz_kapitasi

3.3.) Switch Measurements Table

Parameter Value Units Conditions

Resistance of the10k resistor, R1

9.7 k

ohms with power off anddisconnected from circuit(measured with ohmmeter)

Supply Voltage, V+3.3 3.27

volts Powered(measured with voltmeter)

Input Voltage, VPE0 0.3

volts Powered, butwith switch not pressed(measured with voltmeter)

Resistor current Calculated: 0.03Measured: 0.01

mA Powered, but switch not pressedI=VPE0/R1 (calculated andmeasured with an ammeter)

Input Voltage, VPE0 3.28

volts Powered andwith switch pressed(measured with voltmeter)

Resistor current Calculated: 0.338Measured: 0.307

mA Powered and switch pressedI=VPE0/R1 (calculated andmeasured with an ammeter)

3.4.)Led Measurements Table

Row Parameter Value Units Conditions

1 Resistance of the220 ohm resistor, R10

219 ohms with power off anddisconnected from circuit(measured with ohmmeter)

2 +5 V power supplyV+5

4.98 volts (measured with voltmeter,notice that the +5V power isnot exactly +5 volts)

3 TM4C123 Output, VPE1input to 7406

1.7 volts with PE1 = 0(measured with voltmeter)

Page 7: Lab 4 Report Yildiz_kapitasi

4 7406 Output, Vk-LED k

1.86 volts with PE1 = 0(measured with voltmeter)

5 LED a+, Va+Bottom side of R10

3.5 volts with PE1 = 0(measured with voltmeter)

6 LED voltage 3.5-1.86=1.64 volts calculated as Va+ - Vk-

7 LED current Calculated: 6.7Measured: 6.3

mA calculated as (V+5 - Va+)/R10 andmeasured with an ammeter

8 TM4C123 Output, VPE1`input to 7406

3.28 volts with PE1 = 1(measured with voltmeter)

9 7406 Output, Vk-LED k

0.245 volts with PE1 = 1(measured with voltmeter)

10 LED a+, Va+Bottom side of R10

2.17 volts with PE1 = 1(measured with voltmeter)

11 LED voltage 1.925 volts calculated as Va+ - Vk-

12 LED current Calculated: 12.0Measured: 12.2

mA calculated as (V+5 - Va+)/R10 andmeasured 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******************

Page 8: Lab 4 Report Yildiz_kapitasi

SYSCTL_RCGCGPIO_R EQU 0x400FE608SYSCTL_SCGCGPIO_R EQU 0x400FE708SYSCTL_DCGCGPIO_R EQU 0x400FE808

GPIO_PORTE_DATA_R EQU 0x400243FCGPIO_PORTE_DIR_R EQU 0x40024400GPIO_PORTE_AFSEL_R EQU 0x40024420GPIO_PORTE_PUR_R EQU 0x40024510GPIO_PORTE_DEN_R EQU 0x4002451CGPIO_PORTE_AMSEL_R EQU 0x40024528GPIO_PORTE_PCTL_R EQU 0x4002452C

AREA |.text|, CODE, READONLY, ALIGN=2 THUMB EXPORT StartStart; BL TExaS_Init ; voltmeter, scope on PD3

BL PortE_Init ; initialize input and output pins of Port EMOV R0, #0x02 ; R0 = 0x00000010 (PE1 LED on)BL PortE_Output ; turn the green LED onCPSIE I ;TExaS voltmeter, scope runs on interrupts loop

LDR R0, =ONEMSEC ; R0 = ONEMSEC (delay 62 milisecond) BL delay ; delay at least (3*R0) cycles BL PortE_Input ; read all of the switches on Port E AND R0, R0, #0x01 CMP R0, #0x01 ; R0 == 0x00?

BNE led_on

led_toggle ; else, toggle led

BL PortE_Input ; toggle EOR R0,R0,#0x02 BL PortE_Output ; toggle B loop

led_on MOV R0, #0x02 ; R0 = 0x00000010 (PE1 LED on) BL PortE_Output ; turn the blue LED on B loop

;------------delay------------; Delay function for testing, which delays about 3*count cycles.; Input: R0 count; Output: noneONESEC EQU 9333333 ;approximately 1s delay at ~16 MHz clockONEMSEC EQU 240000 ;approximately 1ms delay at ~16 MHz clockQUARTERSEC EQU 1333333 ;approximately 0.25s delay at ~16 MHz clockdelay

Page 9: Lab 4 Report Yildiz_kapitasi

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, =SYSCTL_RCGCGPIO_R ; 1) activate clock for Port E LDR R0, [R1] ORR R0, R0, #0x10 ; set bit 4 to turn on clock for PE STR R0, [R1] NOP NOP ; allow time for clock to finish

LDR R1, =GPIO_PORTE_DIR_R ;2) set direction register of PE MOV R0,#0xfe ;PE1 output, PE0 and others input STR R0, [R1]

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 ; configure as GPIO MOV R0, #0 ; 0 means configure Port E as GPIO STR R0, [R1]

LDR R1, =GPIO_PORTE_DEN_R ; 5) enable Port E digital port MOV R0, #0xFF ; 1 means enable digital I/O STR R0, [R1]

LDR R1, =GPIO_PORTE_AMSEL_R ; disable analog functionality MOV R0, #0 ; 0 means analog is off STR R0, [R1]

BX LRPortE_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 inputsPortE_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