EECS 373 Midterm 2 Fall 2018

Similar documents
EECS 373 Midterm Winter 2016

EECS 373 Midterm 2 Exam Winter 2018

EECS 373 Midterm Winter 2013

EECS 373 Midterm Winter 2012

EECS 373 Practice Midterm & Homework #2 Fall 2011

EECS 373 Practice Midterm / Homework #3 Fall 2014

EECS 373, Homework 4, Fall 2018 Assigned: Wednesday 10/3; Due: Wednesday 10/10 at 10pm

EECS 373 Midterm Winter 2017

EECS 373 Fall 2018 Homework #3

EECS 373 Design of Microprocessor-Based Systems

esi-multichannel Timer

EECS 373 Design of Microprocessor-Based Systems

EECS 373 Design of Microprocessor-Based Systems

EECS 373 Lab 3: Introduction to Memory Mapped I/O

EECS 373 Design of Microprocessor-Based Systems

EECS 270 Midterm Exam

1 Contents 2 2 Overview 3 3 Hardware Interface 4 4 Software Interface Register Map Interrupts 6 5 Revision History 8

EECS 452 Midterm Closed book part Fall 2010

1 Digital tools. 1.1 Introduction

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

In this lecture, we will focus on two very important digital building blocks: counters which can either count events or keep time information, and

EECS 452 Midterm Closed book part Fall 2010

A 3-SPEED STEPPER MOTOR

May the Schwartz be with you!

Interrupts, timers and counters

Microcomputers. Outline. Number Systems and Digital Logic Review

EECS 473 Midterm Exam

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

EECS 373 Design of Microprocessor-Based Systems

1 Contents. Version of EnSilica Ltd, All Rights Reserved

Final Exam. Date: May 12, 2017

Photoresistor, Transistor, and LED s

Bachelor of Engineering in Computer and Electronic Engineering

Architectural design proposal for real time clock for wireless microcontroller unit

University of Toronto Mississauga. Flip to the back cover and write down your name and student number.

A VHDL 8254 Timer core

MOTENC-Lite 4-Axis PCI Motion & I/O Control Board. Reference Manual Rev 1.1, June 20, Copyright 2005 VITAL Systems Inc

Rotary Encoder Basics

MOTENC Axis PCI Motion & I/O Control Board. Reference Manual Rev 1A, April Copyright 2004 VITAL Systems Inc

Introduction to the MC9S12 Hardware Subsystems

CS/EE Homework 7 Solutions

Unit B - Rotary Encoders B.1

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

IP-Quadrature. Four Channel Quadrature Decoder IndustryPack User s Manual

EE251: Tuesday December 4

University of Florida EEL 3744 Spring 2018 Dr. Eric M. Schwartz. Good luck!

EE445L Fall 2014 Final Version A Page 1 of 7

LCD Display. Other I/O. LCD display Flash ROM SPI EPROM Keyboard (PS/2) UART connectors DAC ADC. 2-line, 16 character LCD display

EE251: Thursday November 30

CN310 Microprocessor Systems Design

Good Evening! Welcome!

EECS 470 Final Exam Fall 2015

Interface DAC to a PC. Control Word of MC1480 DAC (or DAC 808) 8255 Design Example. Engineering 4862 Microprocessors

8051 Microcontroller

TOPIC: Digital System Design (ENEL453) Q.1 (parts a-c on following pages) Reset. Clock SREG1 SI SEN LSB RST CLK. Serial Adder. Sum.

University of Florida EEL 4744 Spring 2014 Dr. Eric M. Schwartz Department of Electrical & Computer Engineering 1 April Apr-14 9:03 AM

Engineering 100 Midterm Exam Technical Part Fall 2010

EECS 470 Midterm Exam Answer Key Fall 2004

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly.

ECE 574: Modeling and Synthesis of Digital Systems using Verilog and VHDL. Fall 2017 Final Exam (6.00 to 8.30pm) Verilog SOLUTIONS

ED1021 I/O Expander with UART interface & analog inputs

MCU: Interrupts and Timers. Ganesh Pitchiah

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

In Class Assignment 2

1 Contents. Version of EnSilica Ltd, All Rights Reserved

Lecture 5: Computing Platforms. Asbjørn Djupdal ARM Norway, IDI NTNU 2013 TDT

EECS 373. Design of Microprocessor-Based Systems. Prabal Dutta University of Michigan. Announcements. Homework #2 Where was I last week?

HC12 Built-In Hardware

END-TERM EXAMINATION

APB4 GPIO. APB4 GPIO Datasheet Roa Logic, All rights reserved

CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

Chapter 10. case studies in sequential logic design

Lab 5: EBI and ADC: Digital Voltmeter

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog

Note: Closed book no notes or other material allowed, no calculators or other electronic devices.

EECS 470 Midterm Exam

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

EECS150 - Digital Design Lecture 17 Memory 2

Input/Output Modes Chapter 8

EE 354 Fall 2015 Lecture 1 Architecture and Introduction

82C54 CHMOS PROGRAMMABLE INTERVAL TIMER

I also provide a purpose-built ADC/DAC board to support the lab experiment. This analogue I/O board in only needed for Part 3 and 4 of VERI.

EECS150, Fall 2004, Midterm 1, Prof. Culler. Problem 1 (15 points) 1.a. Circle the gate-level circuits that DO NOT implement a Boolean AND function.

CPE/EE 421/521 Fall 2004 Chapter 4 The CPU Hardware Model. Dr. Rhonda Kay Gaede UAH. The CPU Hardware Model - Overview

Microcontroller basics

DEV-1 HamStack Development Board

Embedded systems. Exercise session 3. Microcontroller Programming Lab Preparation

EEL 4744C: Microprocessor Applications. Lecture 7. Part 1. Interrupt. Dr. Tao Li 1

Reading Assignment. Interrupt. Interrupt. Interrupt. EEL 4744C: Microprocessor Applications. Lecture 7. Part 1

AvnetCore: Datasheet

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

Nikhil Gupta. FPGA Challenge Takneek 2012

I Introduction to Real-time Applications By Prawat Nagvajara

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

8051 Peripherals. On-Chip Memory Timers Serial Port Interrupts. Computer Engineering Timers

These three counters can be programmed for either binary or BCD count.

ECE 331: N0. Professor Andrew Mason Michigan State University. Opening Remarks

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

BUILDING BLOCKS OF A BASIC MICROPROCESSOR. Part 1 PowerPoint Format of Lecture 3 of Book

Roa Logic. APB4 Multiplexer. Datasheet. October, c Roa Logic B.V.

Transcription:

EECS 373 Midterm 2 Fall 2018 Name: unique name: Sign the honor code: I have neither given nor received aid on this exam nor observed anyone else doing so. Nor did I discuss this exam with anyone after it was given to the rest of the class. NOTES: 1. Closed book/notes. 2. Calculators are allowed, but no PDAs, Portables, Cell phones, etc. Nothing capable of wireless communication! 3. Don t spend too much time on any one problem. If you get stuck, move on!!! 4. You have about 120 minutes for the exam. 5. Be sure to show work and explain what you ve done when asked to do so. Getting partial credit without showing work will be rare. Page 1 of 18

1. Multiple choice/fill-in-the-blank. Pick the best answer. [12 points, 2 each] a. In Verilog an always@* block is generally used to create combinational logic / glitch-free logic / sequential logic / a flip-flop. b. You know a given DAC is monotonic. Which of the following can you then be certain of? the output voltage may go down when the digital input increases. the INL of the converter must be less than 1 LSB. the DNL of the converter must be less than 1 LSB. the output voltage will go down or stay the same when the digital input decreases. none of the above. c. A significant difference between standard UART and I2C transactions is that: I2C allows for full duplex while UART does not. UART has a shared clock wire while I2C does not. I2C requires addresses while UART does not. UART generally requires a pullup resistor while I2C generally does not. d. A significant difference between standard UART and SPI is that: the UART protocol is a standardized and well documented while the SPI protocol is not. UART has a shared clock wire while SPI does not. SPI requires addresses while UART does not. UART generally requires a pullup resistor while I2C generally does not. e. It is useful to have a reference register on a timer because: it allows us to generate interrupts when an event occurs it allows us to generate an interrupt when a certain value is reached it can provide a more precise time of an event than reading the timer in software it provides a way to count the number of events which have occurred in a given amount of time. f. When must data be stable for a correct I²C bus transaction? when the clock is low when the clock is in a high-impedance state when the clock transitions high to low when the clock is high Page 2 of 18

2. Short answer. Each question must be answered in 15 words or less. [10 points, 2 points each] a. Why do we use virtual timers? b. What is the main reason to prefer to use an R/2R ladder DAC rather than a flash DAC? c. What is the main reason to prefer to use a flash DAC rather than an R/2R ladder DAC? d. If we say that we allow preemption, what does that mean in the context of interrupts? e. In the context of a complier, what does a linker do? Page 3 of 18

3. Consider the following C function. int whatfun(int a, float *b, int *c) { int x; x=bob(*b, c); if(x>0) return(x+a+*c); return(9); } Rewrite the above code in Thumb2 assembly for our SmartFusion while following the ABI. You are to assume the bob() function is ABI-compliant and has a prototype of int bob(float, int*). [11 points] Page 4 of 18

4. Consider the following circuit. [6 points] a) Assuming V ref is 4.0V, and there is an INL of ±1/4 LSB, what range of input voltages might cause a value of 100 2 to come out of the encoder? Show your work. [3] b) Given the same assumptions as above, what range of input values are certain to cause a value of 100 2 to come out of the encoder? Show your work. [3] Page 5 of 18

5. Consider the following circuit: Assuming there is no error beyond quantization error, indicate what the value of V out would be given each of the following values of V in. V ref is 4V. [6 points, 2 points each] a) V in=2.2 Volts b) V in=3.3 Volts c) V in=1.1 Volts Page 6 of 18

6. Timers [7 points] You are given a device which contains an 8-bit timer. That timer consists of three 8-bit registers: a count register (CNT) which holds the count value of the timer, a reference register (REF), and a control register (CTL). It also contains a single output EQ that goes high when the counter is enabled and CNT==REF. The CTL register consists of the following fields (0 is the most significant bit): EN (bit 0): Must be set to 1 for the timer to be enabled. RST (bit 1): If this bit is set to 1, CNT will reset to 0 every time the count value reaches the reference value. Otherwise, the timer will continue to increment when the reference value is reached. DIV (bit 2): Setting this bit to 1 divides the system clock by 16 to produce the input clock frequency. If DIV = 0, then the input clock frequency equals the system clock frequency. PRE (bits 3-7, 3 is MSB): A 5-bit prescaler which divides the clock by PRE+1. This division is in addition to the divide by 16 provided by the DIV bit. The system clock runs at 1 MHz. a) What is the maximum range of this timer (how long until it overflows)? What is the resolution (gap between numbers) in that case? [3] Max range: Resolution: b) Say you want EQ to go high every 64ms. Find values of the CTL register and the REF register that will cause that to happen. [4] CTL register (in binary): REF register (in decimal): 7. What is the purpose of the LSB of the PC on the processor we use in lab? Be specific. [3 points] Page 7 of 18

Design Problem: Light Follower Your task is to design a simple light follower using the SmartFusion kit. Two light sensors are mounted on the tips of a T shaft connected to a motor. The device follows a light source by keeping the light reading from the two sensors approximately the same. The system will also keep track of the motors angular position. Figure 1: Two sensors on a T-shaft connected to a motor Read the entire problem before beginning! Motor Control The motor turns at a constant speed when activated and can turn in either direction. A hardware controller is provided for you with the following control features. CCW CW Motor Action 0 0 Stop 0 1 Clockwise 1 0 Counter Clockwise 1 1 undefined Page 8 of 18

Reading the Light Sensors The light sensors produce a voltage proportional to the light level. The voltages will be read with the ADC described below. The ADC converts an analog voltage into an 8-bit unsigned integer. You can assume that its conversion voltage range is matched to the light sensor s output range. Ain 0 and Ain 1: Analog input channel 0 and 1. SEL: Logical 0 selects analog channel 0 and logical 1 selects channel 1. Start: Start is a one clock cycle pulse that starts the conversion. CLK: The ADC clock input. EOC: A one clock cycle pulse that indicates end of conversion. DATA[7:0]: Data is available on this port after the conversion. A conversion is started by issuing a 1 clock cycle pulse to the Start pin. After the converter finishes, a one clock cycle pulse occurs on the EOC pin. Data is then present on the data port and stable until the next start is issued. Light sensor 1 has been connected to Ain 0 and Light sensor 2 has been connected to Ain 1. Rotational Sensor A rotational sensor provides a pulse every 10 degrees the motor is rotated. We will count the pulses from a known starting position to determine the relative position for motor. The pulses can vary in width depending on the speed of rotation, but will always be greater than the system clock. We will use the pulse to generate an interrupt to count the pulses. You may assume a turn is in the direction the motor is currently turning and that no turn will be registered if the motor is not turning. Page 9 of 18

Desired Memory Map There are three devices, each with their own PSEL line: The motor controller, located in the address range 0x40050000-0x400500FF. This is used to control the motor. The hardware has been done for you. The ADC/light sensor, located in the address range 0x40050100-0x400501FF. These locations can be used to select an analog input and start a conversion among other things. When a conversion is completed, it will assert FABINT for one clock. The rotary sensor, located in the address range 0x40050200-0x400502FF. It will assert FABINT for one clock when a new pulse is first detected. Notice that the ADC and rotary sensor both use FABINT. This is handled in two ways: The ADC will actually generate something called FABINT1 and the rotary sensor something called FABINT2. Those two signals will be ORed together into a single FABINT signal sent to the processor. The hardware for this (an OR gate) has been done for you. The other problem is figuring out which device generated the interrupt. The ADC and rotary sensor each have a memory-mapped register which will be asserted when their event occurs and can be cleared from software. Address Usage Register Description 0x40050000 Read/Write Bit 0 is mapped to CW of the motor controller. Bit 1 is mapped to CCW of the motor controller. All other bits are zeros when read and have no effect when written. The motor will turn in the direction specified until the next time this address is written. The hardware for this is done for you. 0x40050100 Read/Write If bit 0 was last written as a 0, Ain 0 will be used as the analog input. If a 1 was last written to bit 0, Ain 1 will be used as the analog input. 0x40050104 Write only When this register is written (with any value), a new ADC conversion is started. When it finishes, FABINT will be asserted. 0x40050108 Read only The lower 8 bits of this register are to hold the results of the last ADC conversion done. 0x4005010C Read/Write This register will be set to a 1 once an analog to digital conversion has finished and will stay so until a write is done to this register (which will clear the bit). 0x40050200 Read/Write This register will be set to a 1 if the rotary sensor has the start of a pulse and will stay so until a write is done to this register (which will clear the bit). Table 1: Memory Mapped Registers for the Three Devices Page 10 of 18

Desired System Behavior A timer has been configured to generate an interrupt every 100ms. That interrupt will cause the ISR Timer_IRQHandler to run. That ISR is to start a new ADC conversion of one of the light sensors. Each time it should change which sensor is being sampled. We do not want to wait in any ISR for the ADC to complete its conversion. We want the main program to be able to run during that conversion. Finally, you should design the system so that the following things happen: If sensor 1 has the higher value (is brighter), the motor should turn clockwise. If sensor 2 has the higher value, the motor should turn counter clockwise. Otherwise it should stay still. Every time the rotary sensor detects a pulse, a global variable named FACING should be incremented (if we are currently turning clockwise) or decremented (if currently turning counter clockwise). Assume the variable is a signed integer that has already been declared. You may freely declare other global variables as needed. Page 11 of 18

Part 1: ADC Hardware Design [17 points] Complete the hardware design implementing the ADC interface and interrupt generation for the ADC. There is additional space on the next page for your answer. module control( /*** APB3 BUS INTERFACE ***/ input PCLK, // clock input PRESERN, // system reset input PSEL, // peripheral select input PENABLE, // distinguishes access phase output wire PREADY, // peripheral ready signal output wire PSLVERR, // error signal input PWRITE, // distinguishes read and write cycles input [31:0] PADDR, // I/O address input wire [31:0] PWDATA, // data from processor to I/O device (32 bits) output reg [31:0] PRDATA, // data to processor from I/O device (32-bits) /*** I/O PORTS DECLARATION ***/ output wire FABINT, ); //ADC: output wire ADC_SEL, output wire ADC_CLK, output wire ADC_Start, input EOC, input [7:0] ADC_Data assign ADC_Clock=PCLK; Page 12 of 18

Extra Page for Part 1 Page 13 of 18

Part 2: Rotary Interrupt Hardware Design [8 points] Complete the hardware design below in schematic form that implements the rotary sensor. You may use: D flip-flops with CE (clock enable) and/or reset. Standard gates (AND, OR, XOR with any number of inputs) as well as inversion bubbles as a shorthand for NOT gates. Tri-state buffers with multiple inputs and outputs. You may use signal labels to show signal connections rather than drawing lines. For example, you can use the name PCLK for all the clock names instead of drawing wires. Input signals are on the left, output signals are on the right. PRDATA[31:0] PCLK PSEL PREADY PENABLE PWRITE PADDR[7:0 PWDATA[31:0 FABINT2 Rotary Pulse Page 14 of 18

Part 3: System Control (Timer Interrupt) [7 points] Provide the code in C for the timer IRQ handler. Declare any global variables used above this function. _attribute_((interrupt)) void Timer_IRQHandler( void ) { Page 15 of 18

Part 4: Fabric Interrupt [13 points] Complete the design by writing the function below in C. You may declare any needed global variables that you didn t declare in part 3 above the function. _attribute_((interrupt)) void Fabric_IRQHandler( void ) { Page 16 of 18

Extra Page for Part 4 Page 17 of 18

References Page 18 of 18