ECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class)

Similar documents
ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #8: Making it work: LEDs, Buttons & Keypad

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #9: Exam Review w/ Solutions

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #7: More Digital IO

ECE2049-E17 Lecture 6 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review

ECE2049-E18 Lecture 6 Notes 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review

ECE2049 E17 Lecture 4 MSP430 Architecture & Intro to Digital I/O

ECE2049 HW #1-- C programming and Binary Number Representations (DUE Friday 8/31/2018 At the BEGINNING of class)

ECE2049 HW #1-- C programming and Binary Number Representations (DUE 9/1/2017 At the BEGINNING of class)

ECE2049 HW #1-- C programming and Binary Number Representations (DUE 1/19/2018 At the BEGINNING of class)

Using peripherals on the MSP430 (if time)

Review Activity 1 CALL and RET commands in assembler

ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives:

Why embedded systems?

ECE PRACTICE EXAM #2 Clocks, Timers, and Digital I/O

Lecture test next week

Before next weeks lab:

Reading: Davies , 8.3-4, , MSP430x55xx User's Guide Ch. 5,17

MIDTERM#1. 2-(3pts) What is the difference between Von Neumann & Harvard processor architectures?

Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

ECE2049: Homework 1. Consider the following code to compute the average of your exam grades: #define NUM_EXAMS (3)

Texas Instruments Microcontroller HOW-TO GUIDE Interfacing Keypad with MSP430F5529

PHYS 319. Things to do before next week's lab Whirlwind tour of the MSP430 CPU and its assembly language Activity 1.

Getting Started with the Texas Instruments ez430

Reading: Davies , 8.3-4, , MSP430x55xx User's Guide Ch. 5,17, MSP430F5529 Launchpad User's Guide

ECE2049 Embedded Computing in Engineering Design. Lab #0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

Lecture 5: MSP430 Interrupt

ECE2049: Homework 1. Due: Thursday, 25 May 2017 by 7pm

Basic System Memory Architecture View (Functional)

Welcome to Lab! Feel free to get started until we start talking! The lab document is located on the course website:

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #3: Of Integers and Endians (pt. 2)

6. General purpose Input/Output

Choosing a Micro for an Embedded System Application

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #11: More Clocks and Timers

Welcome to Lab! You do not need to keep the same partner from last lab. We will come around checking your prelabs after we introduce the lab

Copyright 2015 by Stephen A. Zajac & Gregory M. Wierzba. All rights reserved..spring 2015.

CPE/EE 323 Introduction to Embedded Computer Systems Homework III

Microcomputer Architecture and Programming

8051 Microcontroller

Lecture Objectives. Introduction to Computing Chapter 0. Topics. Numbering Systems 04/09/2017

/* defines are mostly used to declare constants */ #define MAX_ITER 10 // max number of iterations

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #20: Using SPI The DAC

CONTENTS: Program 1 in C:

C Language Programming through the ADC and the MSP430 (ESCAPE)

Announcements Homework #3 due today. Ports. Outline for Today C8051 SFRs & Port I/O Worksheet #4 - simple I/O code. Using Ports

Magic 8 Ball. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

Embedded Systems. 3. Hardware Software Interface. Lothar Thiele. Computer Engineering and Networks Laboratory

MICROCONTROLLERS 8051

Embedded Systems - FS 2018

IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -2 1 UNIT 2

ARM Architecture and Assembly Programming Intro

@databasescaling Wednesday, 18 th April 2013

SIGNED AND UNSIGNED SYSTEMS

1. Attempt any three of the following: 15

Programming Using C Homework 5

The due date for submitting this assignment has passed. 1) Which of the following statements regarding a microcomputer, a

Microprocessor and Microcontroller question bank. 1 Distinguish between microprocessor and microcontroller.

Embedded Systems - FS 2018

ECE2049: Embedded Systems in Engineering Design Lab Exercise #3 C Term Making a Time and Temperature Display

Interrupts, Low Power Modes

Introduction to EZ430 RF2500

IAS0430 MICROPROCESSOR SYSTEMS

Lecture 1: Introduction to Microprocessors

C:\Users\jacob\Documents\MtSAC\ELEC74 Mt SAC - chipkit\homework Sheets.docx

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

Create and Add the Source File

ECE 4510/5530 Microcontroller Applications Week 7

Interfacing CMA3000-D01 to an MSP430 ultra low-power microcontroller

Physics 319 Spring 2015: Introduction to the Programming and Use of Microprocessors

Block diagram of processor (Harvard)

Microcontrollers. Microcontroller

CPE 323 Introduction to Embedded Computer Systems: MSP430 System Architecture An Overview

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018

2. (2 pts) If an external clock is used, which pin of the 8051 should it be connected to?

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls

UART Devices. ECE 480: Design Team 3. Application Note. By: Hoyoung Jung. Date: 4/3/15

ME 475 Lab2 Introduction of PIC and Programming. Instructor: Zhen Wang

Texas Instruments Mixed Signal Processor Tutorial Abstract

C:\Users\Jacob Christ\Documents\MtSAC\ELEC74 Mt SAC - chipkit\homework Sheets.docx

EECS 373 Practice Midterm / Homework #3 Fall 2014

CSE 141L Computer Architecture Lab Fall Lecture 3

Timers and Clocks CS4101 嵌入式系統概論. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

Interrupts CS4101 嵌入式系統概論. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

ME 6405 Introduction to Mechatronics

Course Introduction. Purpose: Objectives: Content: 27 pages 4 questions. Learning Time: 20 minutes

3. (a) Explain the steps involved in the Interfacing of an I/O device (b) Explain various methods of interfacing of I/O devices.

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

Introduction to Computer Science Midterm 3 Fall, Points

CSC201, SECTION 002, Fall 2000: Homework Assignment #2

EE 308: Microcontrollers

Module I. Microcontroller can be classified on the basis of their bits processed like 8bit MC, 16bit MC.

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B DIGITAL SYSTEMS II Fall 1999

Systems Programming. Lecture 4 Z16 Architecture and Programming

CS101 Lecture 25: The Machinery of Computation: Computer Architecture. John Magee 29 July 2013 Some material copyright Jones and Bartlett

Intro to Programming 2017

7 8 9 C. PRELAB REQUIREMENTS You must adhere to the Lab Rules and Policies document for every lab.

Code Composer Studio. MSP Project Setup

Introduction to Embedded Systems

Fig 1. Block diagram of a microcomputer

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

Transcription:

ECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class) Your homework should be neat and professional looking. You will loose points if your HW is not properly submitted (by properly I mean stapled, no ruffled edges, with a cover sheet including your ECE box number)! Always review any reading assignments before attempting the homework. Show all of your work. Clearly indicate results (underline, circle or box). Always write neatly. Code should be typed and properly indented for clarity. The grader can not be expected to GUESS what you meant to do! Reading -- Davies Ch 3, 4 & 7, MSP430x5xx User's Guide Ch 6.1, 6.3,12, MSP430F5529 datasheet, MSP-EXP430F5529 User's Guide (see Useful Links page on class website) 1) In lab we are using the MSP430F5529 instead of the MSP430F2013 that the Davis text book discusses. Using the MSP430x5xx Datasheet and MSP430F5529 User's Guide (under Useful Links on the class website) and class notes, fully answer the following questions about the architecture and memory map of the MSP430F5529. (25 pts) a) The MSP430 uses a von Neumann achitecture. What is the main difference between the Harvard architecture and the VonNeumann architecture? Sketch both architectures showing CPU, memory, peripherals and all buses. Name one strength and one weakness for each architecture b) The MSP430F5529 memory space contains both RAM and FLASH. Why? What is the difference between RAM and FLASH? Why not use just RAM or just FLASH? c) Flash serves a number of purposes in the MSP430. How much Flash memory does the MSP430F5529 have? Into how many banks is code memory divided? How many bytes per bank? Which bank of code memory contains the address 0x0CFA6? d) How much RAM does the MSP430F5529 have and how is it organized (number of banks, etc). What is the beginning address of RAM? What is RAM used for? e) In lab, when CCS downloads a program to the MSP430F5529, where is the executable code stored? Beginning at what address? f) When you declare a local variable inside your main() where in memory is that value stored? What if you declared a global variable, where in memory are globals stored?

g) Why does the MSP430F5529 have a 20-bit address bus when its word size is 16 bits? Also why are registers R0 (i.e. Program Counter) and R1 (the Stack Pointer) 20 bit registers instead of 16 bit? h) What is the address for Port 6 direction register, the Port 3 input register, and the Port 7 select register. (See Datasheet Tables 19-33). i) What MSP430 peripheral device uses addresses 00700h-0073Fh? What package pins numbers are used for Port 8 digital IO? j) Most of the MSP430F5529 package pins have multiple functions that are selected using a select register. Why are all these pins multiplexed? What functionality is multiplexed with the Port 4.4-4.7 digital I/O? With Port 2.2 and 3.3? What package pin(s) is analog V cc and which package pin(s) is GND (V ss )?

2) The MSP430 is a small, 16-bit microcontroller. The device's forte is that it is capable of remarkably low power operation. It is not a processor suited to computationally heavy applications. It is a fixed point (i.e. integer) processor. That means the CPU contains a digital circuit called the Arithmetic Logic Unit (ALU) which performs addition and subtraction and the logic operations AND, OR, NOT and XOR on integers but it does not contain a Floating Point Unit (FPU). That is, there is no circuit inside an MSP430 that performs arithmetic operations on floating point numbers. The Code Composer Studio compiler does provides full support for floating point operations, as all C compilers must, but all floating point math on an MSP430 is emulated in software which has significant implications for both code size and run time. (10 pts) i. Add a comment to each line of code below saying what it does. ii. Run these 2 simple programs in Code Composer Studio. Take a screen capture of each being run in the debugger. iii. Comment on the efficiency (both memory space and run-time) of the integer math program vs the floating point program. Hint: The Console window in the debugger gives the code size at the bottom. You should also look at the size of the equivalent assembly code produced for each program in the Disassembly window. You may assume that it takes an average of 4-6 instruction cycles per assembly instruction to execute. a) #include "msp430.h" #include <stdlib.h> #define MAX_PTS 300 // // IMPORTANT: PUT YOUR NAME AND ECE BOX NUMBER HERE!!! void main(void) // Give total size (in bytes) of these variables as declared int in[max_pts]; // float out[max_pts]; // volatile int i, a, SPAN=2500, OFFSET=499, M=8; // WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer for (i = 0; i < MAX_PTS; i++) // in[i] = (rand() % SPAN) - OFFSET; // if (i < M) // out[i] = 0.0; // else // out[i] = 0.0; // for (a = 0; a < M; a++) // out[i] += (float)in[i-a]; // out[i] = out[i]/m; //

b) #include "msp430.h" #include <stdlib.h> #define MAX_PTS 300 // #define M 8 // #define SHIFT 3 // #define SPAN 2500 // #define OFFSET 499 // // IMPORTANT: PUT YOUR NAME AND ECE BOX NUMBER HERE!!! void main(void) // Give total size (in bytes) of these variables as declared int in[max_pts]; // int out[max_pts]; // volatile int i,a; // long int sum; // WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer for (i = 0; i < MAX_PTS; i++) // in[i] = (rand() % SPAN) - OFFSET; // if (i < M) // out[i] = 0; // else // sum = 0; // for (a = 0; a < M; a++) // sum += in[i-a]; // out[i] = sum >> SHIFT; //

3) Write the following functions using CCS C to complete the code framework below. You do not have to compile this code but your code must be typed to be graded. (20 pts) (a) A function setupp2_p3() that selects P3.7-4 for digital IO with those bits set as outputs and selects P2.7-4 for digital IO with those bits set as inputs. The inputs P2.7-4 are connected to external switches and require internal pull-down resistors. When the switch is open, a logic 0 is input and when the switch is closed, a logic 1 is input. None of the settings for P2 or P3 should be altered. Default drive strength is fine. (b) A function in2_out3() that reads in from P2.7-4 to determine which switches are open and which are closed. The function then outputs a logic 1 on P3.7-4 if the switch on the correspond port 2 input is closed and a logic 0 if it is open (i.e. P2 pin 4 input corresponds to P3.4 output, P2.5 P3.5, etc.). (c) Write a simple main() that sets up any variables and shows how your functions would be used. What value would result in P3OUT in your in2_out3() function if P2IN =0xB4? If P2IN =0x8F? Does it matter what the values of P3IN or P2OUT are? Explain. /* Compiler directives (includes and defines) */ #include "msp430.h" /* Function prototypes */ void setupp2_p3(); void in2_out3(); /*** Implement your functions here ***/... /* Write your main() here */ void main()

4) Our MSP430F5529 Launchpad-based lab board has several digital IO devices on it including 6 LEDs, 6 push buttons, and a 3 x 4 keypad. (20 pts) (a) Referring to resources like the MSP430F5529 Launchpad User's Guide and posted schematics for our lab board, fill out a table like the one below listing all the ports, pins, and MSP430F5529 package pins to which each of these devices is connected. This will be very useful to have in labs. (5 pts) Device I/O Port and Pins MSP430F5529 Package Pins 4 Lab Board Buttons 2 Launchpad User Buttons 4 Multi Colored LEDs 2 Launchpad Used LEDs Keypad (shown below) (b) Draw out the schematic showing how Lab board button S2 is connected. What logic value results when button S2 is pressed? Which, if any, of the devices in the table above would require configuration of the internal pull resistors? Fully explain your answers. Hint: Refer to the Lab board schematics and the schematics at the end of the MSP430- F5529 Launchpad User Guide, both under Useful Links. (2.5 pts) (c) Are the 2 user LEDs on the Launchpad inputs or outputs? How do you know? What logic level (1 or 0) will cause the user LEDs to light? Explain your answer. (2.5 pts) (d) Here is the keypad configuration function and part of the getkey function which from the demo project and how column 1 of the keypad is connected to the MSP430F5529. void configkeypad(void) // Configure digital IO for keypad // smj -- 27 Dec 2015 // Col1 = P1.5 = // Col2 = P2.4 = // Col3 = P2.5 = // Row1 = P4.3 = // Row2 = P1.2 = // Row3 = P1.3 = // Row4 = P1.4 =

// Select pins for digital IO P1SEL &= ~(BIT5 BIT4 BIT3 BIT2); P2SEL &= ~(BIT5 BIT4); P4SEL &= ~(BIT3); // Columns are? P2DIR = (BIT5 BIT4); P1DIR = BIT5; P2OUT = (BIT5 BIT4); // P1OUT = BIT5; // // Rows are? P1DIR &= ~(BIT2 BIT3 BIT4); P4DIR &= ~(BIT3); P4REN = (BIT3); // P1REN = (BIT2 BIT3 BIT4); P4OUT = (BIT3); // P1OUT = (BIT2 BIT3 BIT4); From getkey() P1OUT &= ~BIT5; P2OUT = BIT4; P2OUT = BIT5; if ((P4IN & BIT3)==0) ret_val = '3'; if ((P1IN & BIT2)==0) ret_val = '6'; if ((P1IN & BIT3)==0) ret_val = '9'; if ((P1IN & BIT4)==0) ret_val = '#'; P2OUT = BIT5; Fully describe the operation of the keypad. Indicate whether the various pins P1.5, P2.4,P2.5,P4.3,P1.2,P1.3 and P1.4 are inputs or outputs. On which ports and pins are the pull resistors being used. Are they pull up or pull down. Why are they necessary? Fully describe how the column read (from getkey ) works. To what logic value (0 or 1) must P1.5 be set to be able to detect a key press in one of the rows in column 1. Explain. (10 pts) P1.5 col 1 of keypad P4.3 MSP430F 1 Pressing the key closes the switch 5529 P1.2 4 P1.3 7 P1.4 *

5) Assume that 4 slide switches like the one shown below are to be connected to the pins of Port 2 pins 6-3 such that when the switch is slid to the right it connects that pin to GND (0V) and when slid to the left it connects to V cc (3.3V). (20 pts) (a) Would these switches be digital inputs or outputs? How would they work (i.e. what switch operation would correspond to digital 1 or digital 0)? 3.3V P2.x GND (b) Describe an example application for these switches. How might they be used? How is their functionality different from the push buttons (i.e. Why would you choose use slide switches instead of buttons)? (c) Write 2 functions in Code Composed Studio C to configure and use the switches and a simple main which uses your functions. The function switchconfig() should configure P2.6-3 for digital IO. You should leave Drive Strength in its default configuration and disable pull up/ pull down resistors. The settings for all other Port 2 pins should not be altered. The function switchio() should return a value between 0- F hex which corresponds to the switch settings assuming P2.3 is the LSB and P2.6 is the MSB. You do not have to compile this code but it does need to be typed. /* Function prototypes */ void switchconfig(); char switchio(); (d) Assume your program has properly configured the 4 slide switches for digital IO. How would your functions interpret the following settings of the Port 5 input and output registers P2IN = 0xB5 and P2OUT = 0x08, and P2IN = 0x6C and P2OUT = 0x00? What would the function switchio() return in each case?

ECE2049 Homework #2 Submitted by: ECE Box #: Date: Question Grade 1-- 25 2-- 10 3-- 20 4-- 20 5-- 25 Total: 100