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

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

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

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

Lab 4: Interrupt. CS4101 Introduction to Embedded Systems. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

ECE2049: Embedded Computing in Engineering Design C Term Spring 2019 Lecture #22: MSP430F5529 Operating Mode & the WDT

CPE 323: MSP430 Timers

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

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

ECE2049: Embedded Computing in Engineering Design A Term Fall 2017 Lecture #16: Interrupts and Event Driven Code

Texas Instruments Mixed Signal Processor Tutorial Abstract

Lecture 5: MSP430 Interrupt

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

// Conditions for 9600/4=2400 Baud SW UART, SMCLK = 1MHz #define Bitime_5 0x05*4 // ~ 0.5 bit length + small adjustment #define Bitime 13*4//0x0D

CPE 325: Embedded Systems Laboratory Laboratory #7 Tutorial MSP430 Timers, Watchdog Timer, Timers A and B

Lab 4 Interrupts ReadMeFirst

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

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

Lab 1: I/O, timers, interrupts on the ez430-rf2500

2.996/6.971 Biomedical Devices Design Laboratory Lecture 6: Microprocessors II

Timer Module Timer A. ReadMeFirst

CPE 325: Embedded Systems Laboratory Laboratory #11 Tutorial Analog-to-Digital Converter and Digital-to-Analog Converter

Getting Started with the Texas Instruments ez430

What is an Interrupt?

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

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

MSP430 Interrupts. Change value of internal variable (count) Read a data value (sensor, receive) Write a data value (actuator, send)

MSP430. More on MSP430

Block diagram of processor (Harvard)

Hacettepe University

Fall. Accelerometer RGB LED control Vishal Shah Rebel Sequeira Pratiksha Patil Pranali Dhuru Chris Blackden. George Mason University

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

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

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

CPE/EE 323 Introduction to Embedded Computer Systems Homework V

Hacettepe University

CPE 323 Introduction to Embedded Computer Systems: ADC12 and DAC12. Instructor: Dr Aleksandar Milenkovic Lecture Notes

IAR PowerPac RTOS for Texas Instruments MSP430 Microcontroller Family

Analog Peripherals. Introduction. Objectives


ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #15: More ADC Examples

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

Using peripherals on the MSP430 (if time)

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

Interrupts, Low Power Modes

15.1 Timer_A Introduction

@databasescaling Wednesday, 18 th April 2013

Towards Hard Real-time Performance in a Highly Asynchronous Multitasking MSP430 Application Andrew E. Kalman, Ph.D.

5xx Active & Low Power Mode Operation

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

Why embedded systems?

Alex Milenkovich 1. CPE/EE 421 Microcomputers: The MSP430 Introduction. Outline

Using programmed I/O on the M16C; and Writing an Interrupt Service Routine (ISR)

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

The 16-bit timer/counter register, TAR, increments or decrements (depending on mode of operation) with each rising edge of the clock signal.

Moses Jones Application Note ECE 480 Design Team 7 Programming Altimeters. Using MSP 430 Launch Pad 11/8/2013

MSP430 Teaching Materials

Wireless Sensor Networks (WSN)

Lecture test next week

Chapter 2. Overview of Architecture and Microcontroller-Resources

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz IV

Interrupts and Timers

Supporting Information for. Simultaneous Atomic-Level Visualization and High Precision

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

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

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang,

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

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz III

Timer 32. Last updated 8/7/18

6. General purpose Input/Output

ECE 492 WINTER 2015 GROUP 2. Texas Instruments MSP430-FR Bit ADC Setup Guide

Introduction to Embedded Systems

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab

ADC 14. Last updated 9/1/18

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

OPERATIONAL AMPLIFIER

OPERATIONAL AMPLIFIER

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

The following article introduces and shows an example of how to set up and use the watchdog timer on the M16C/26 microcontroller (MCU).

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

EE 472 Embedded Systems. Name solutions. Instructions:

CPE/EE 421 Microcomputers

Designing for Ultra-Low Power with MSP430

CONTENTS: Program 1 in C:

Salvo Compiler Reference Manual CrossWorks for MSP430

UNCA CSCI 255 Exam 3 Fall 2011

Alex Milenkovich 1. CPE/EE 421 Microcomputers. Course Administration. Review: Outline. Getting Started with EasyWeb2. Review: MSP bit RISC

Week 4: Embedded Programming Using C

Network Embedded Systems Sensor Networks. Tips and Tricks. Marcus Chang,

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

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

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

Computer Software Requirements for Real-Time Applications

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

Team 3. By: Miriel Garcia. Microcontrollers/ TI MSP430F5438A. ECE 480 senior Design. Application Note 4/3/15

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

The MC9S12 Timer Input Capture Function

Interrupts & Interrupt Service Routines (ISRs)

CPE/EE 421 Microcomputers

ADC: Analog to Digital Conversion

Exam TI2720-C/TI2725-C Embedded Software

Transcription:

ECE2049 -- PRACTICE EXAM #2 Clocks, Timers, and Digital I/O Study HW3, Class Notes, Davies Ch 2.6, 5.8, 8, 9.2-3, 9.7, MSP43F5529 User's Guide Ch 5, 17, 28 Work all problems with your note sheet first THEN look at solutions! 1. Answer the questions below completely. (25 pts) a. What are the default frequencies for ACLK, MCLK and SMCLK on the MSP430F5529 after power up? What is the purpose of these various clock signals (i.e. What are they used for)? b. How does the CPU know where to go on an interrupt? How does it find the correct ISR? c. Explain the operation of a Timer in up mode (ie. What happens to the timer count? When is an interrupt triggered?). d. True or False: The operation of peripherals like the Timers or ADC12 causes a big drain on CPU speed. Why or why not? e. True or False: Interrupt Service Routines (ISRs) should be kept short because the CPU will stop executing them after 255 instructions. ECE2049-E16 Practice Exam 2 Page 1 of 6

2. Answer the questions using the Timer A2 configuration code below. Assume that the MSP430F5529's system clocks are running in their default configuration. (25 pts) void runtimera2(void) TA2CTL = TASSEL_1 + MC_1 + ID_0; TA2CCR0 = 16383; TA2CCTL0 = CCIE; a) Explain exactly how TimerA2 is configured to run. Specifically what is the clock source, the clock divider, the resulting clock frequency, the counting mode, and the value of the maximum count? Is the counter's interrupt enabled? Explain the operation of the counter when the program is executing. b) Now disregard any of the settings above. Instead, assume TimerA2's interrupts are enabled and the clock source is set to ACLK and TA2CCR0 = 24000. What would be the time between interrupts if Continuous Mode were selected? What if Up-down Mode were selected? c) Set TimerA2's control registers to use SMCLK to count intervals 25 milliseconds. d) How long until a clock based on the timer from part (c) would be off by 0.025 sec? Is it fast or slow? ECE2049-E16 Practice Exam 2 Page 2 of 6

Note: This problem is longer than a standard exam problem. However, it is good practice and demonstrates all of the concepts you need for this exam! Give it a try! 4. You want to use an MSP430 to measure a person s reaction time. A simple way to do this is to have a person watch for an LED to turn on, and make them press a button as soon as they see it. You can compute the reaction time by measuring the time when the LED was turned on and when the button was pressed, and comparing the difference. In this problem, you will design a system to do this. (25 pts) a. Assume you have one LED and one button and want to connect them to your MSP430 board on P1.0 and P1.1, respectively (that is, connect the LED to P1.0 and the button to P1.1). Draw a schematic showing how you would connect these to your MSP430. You can connect them in any way you want, so long as it works. (Assume that you also have access to some resistors, should you choose to use them.) b. Based on your configuration, what logic level results when the button is pressed? What logic level turns on the LED? ECE2049-E16 Practice Exam 2 Page 3 of 6

c. Complete the following C function to configure the Digital I/O registers to use the button and LED you configured in part (a). void setupio(void) d. Complete the function buttonpressed() below such that it returns a 1 when your button from parts (a) and (b) is pressed and 0 when it is unpressed. // Returns 1 when button on P1.1 is pressed, 0 when unpressed char buttonpressed(void) (continued on the next page) ECE2049-E16 Practice Exam 2 Page 4 of 6

Now suppose you have written a main() function like the following to measure the reaction time. The example configures a timer that increments the variable timer at 10ms intervals. Example code for the rest of the program can be found on the next page. e. Complete the main() function below to use the timer value to measure the user s reaction time. To do this, you will need to add a few lines of code and fill in the computation for diff. You may declare additional variables as necessary. Hint: You do not need a lot of code for this. Keep it simple! // Global time count (increments every 10ms) volatile unsigned long timer = 0; #pragma vector=timer2_a0_vector interrupt void TimerA2_ISR(void) // Timer A2 ISR timer++; // Increment global time count void main(void) WDTCTL = WDTPW WDTHOLD; // Stop watchdog timer // Initialize peripherals setupio(); starttimera2(); enable_interrupt(); // Global interrupt enable while (1) // Forever loop randdelay(); // Wait for a random amount of time setled(1); // Turn on the LED while(readbutton()!= 1) // Do nothing until a button is pressed // Compute reaction time unsigned long diff = displaytimems(diff); // Display the reaction time setled(0); // Turn off LED // end while (1) ECE2049-E16 Practice Exam 2 Page 5 of 6

// Function Prototypes void swdelay(char numloops); void starttimera2(void); void randomdelay(void); void displaytimems(unsigned long curr_time); char buttonpressed(void); void setled(char value); void starttimera2(void) // Use ACLK, 16 bit, Up mode, Divide by 1 TA2CTL = TASSEL_1 MC_1 ID_0; TA2CCR0 = 327; // 327 + 1 = 328 ACLK ticks = ~1/100 seconds TA2CCTL0 = CCIE; // Enable TA2CCR0 interrupts char buttonpressed(void); void setled(char value) // void randdelay(void) // void displaytimems(unsigned long curr_time) //... // Other demo functions omitted... ECE2049-E16 Practice Exam 2 Page 6 of 6