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

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

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

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

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

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

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

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

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

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

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

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

ECE2049 E17 Lecture 2: Data Representations & C Programming Basics

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

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

Why embedded systems?

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

Review Activity 1 CALL and RET commands in assembler

COMP2611: Computer Organization. Data Representation

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

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

Microcontrollers. Microcontroller

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Lecture 1: Introduction to Microprocessors

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

MIPS Assembly: Practice Questions for Midterm 1 Saving to and Loading from Memory CS 64: Computer Organization and Design Logic Lecture #6

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring:

World Inside a Computer is Binary

Using peripherals on the MSP430 (if time)

Embedded programming, AVR intro

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

EE251: Tuesday December 4

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

The type of all data used in a C++ program must be specified

Time (self-scheduled): Location Schedule Your Exam: What to bring:

Information Science 1

CS/ECE 5780/6780: Embedded System Design

Week 1. Introduction to Microcomputers and Microprocessors, Computer Codes, Programming, and Operating Systems

CS1004: Intro to CS in Java, Spring 2005

SISTEMI EMBEDDED. Basic Concepts about Computers. Federico Baronti Last version:

Computer Organization and Assembly Language. Lab Session 01

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10?

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

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

COMP2121: Microprocessors and Interfacing. Number Systems

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

CS107, Lecture 3 Bits and Bytes; Bitwise Operators

MICROPROCESSORS A (17.383) Fall Lecture Outline

Integer Representation

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

MACHINE LEVEL REPRESENTATION OF DATA

MICROPROCESSORS A (17.383) Fall Lecture Outline

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

COMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?

UNIT 7A Data Representation: Numbers and Text. Digital Data

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 01, SPRING 2013

Computer Organization and Programming

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

30 August CS101L PROGRAMMING LAB 2

COMPUTER ORGANIZATION AND ARCHITECTURE

Few reminders and demos

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

Computer (Literacy) Skills. Number representations and memory. Lubomír Bulej KDSS MFF UK

Microcomputer Architecture and Programming

Number Systems & Encoding

Internal architecture of 8086

Embedded Systems - FS 2018

Basic System Memory Architecture View (Functional)

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

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers

Lecture 2: Number Systems


Ali Karimpour Associate Professor Ferdowsi University of Mashhad

LAB WORK NO. 2 THE INTERNAL DATA REPRESENTATION

Information Science 1

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

Final Labs and Tutors

ENE 334 Microprocessors

Instruction Set Architecture

Computer Organization and Levels of Abstraction

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

The type of all data used in a C (or C++) program must be specified

ECE2029: Introduction to Digital Circuit Design Lab 3 Implementing a 4-bit Four Function ALU

Show how to connect three Full Adders to implement a 3-bit ripple-carry adder

Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document. Solutions to Number Systems Worksheet. Announcements.


ET355 Microprocessors Thursday 6:00 pm 10:20 pm

MECE336 Microprocessors I

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

CS 261 Fall Binary Information (convert to hex) Mike Lam, Professor

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

Introduction to Computers and Programming. Numeric Values

SIGNED AND UNSIGNED SYSTEMS

Name: CMSC 313 Fall 2001 Computer Organization & Assembly Language Programming Exam 1. Question Points I. /34 II. /30 III.

Embedded Systems - FS 2018

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Transcription:

ECE2049-E17 Lecture 6 1 ECE2049: Embedded Computing in Engineering Design E Term 2017 Lecture #6: Exam Review Administrivia Exam 1: Next Tuesday (6/6) HW2: Due Tonight at 7pm Lab 1: Due next Tuesday (6/6), but try to finish this week! Lab 2: Starts today! The exam will be closed book and notes but you may use the following: >> One 8.5 x 11 sheet of notes (both sides) & a calculator -- You will need a calculator for number conversions! -- I will supply a table of the ASCII character codes All cell phones, computers, PDAs, etc are to be OFF and inside a book bag What to study?? >> Lecture notes 1-6, Reading, HW1 and HW2!! Basic C Instructions and Syntax: >> Know layout of C source file (Lecture 2) >> Some Data types (as they are defined in CSS for the MSP430) int a; // 16 bit signed (2's comp) integer float b; // 32 bit IEEE float point char c; // 8 bit unsigned character unsigned int d; // 16 bit unsigned integer long int e; // 32 bit signed integer double f; // 64 bit in IEEE float point int arr[5]; // array of five 16 bit integers >> Array names point to the beginning of a block of memory where multiple values are stored successively in memory > Convenient way to store and index groups of values

ECE2049-E17 Lecture 6 2 >> Standard C Operators: Math: + - * / = % (modulo) Unary: ++ -- (also = &= += etc.) Relational and Logical: > >= < <= ==!= && Bitwise: & (AND) (OR) ^ (XOR) >> (R shift) << (L shift) ~ (NOT) >> Decisions, looping, etc: if (kk > 100) kk = 0; } else z = 2*z+kk; kk++; } while (j < 100 ) /* Body of loop */ j++; } // end while for (i = strt; i < end_pt; i++) /* Body of loop. Do something */ } // end for i --> The Forever Loop while (1) /* Body of loop. Do something */ } // end while (1)

ECE2049-E17 Lecture 6 3 C is a modular programming language >> Use functions to implement small blocks of code that can be used repeatedly >> A C main() calls a series of smaller functions to complete a task. Execution of a C program always starts at main()! #define MAX_SZ 100; // Determines max value of an array unsigned int arraymax(unsigned int* in_arr, int num_pts); void main() Float unsigned int unsigned int unsigned int myarray[10]; big[max_siz]; maximum=0 i, other_val; /* Do some stuff */ i = 0; while (i < MAX_SZ) big[i] = (i % 10); i++; } maximum = arraymax(big, MAX_SZ); /* Do more stuff */ } // end of main() Quick Questions: 1) How many times does the while loop execute? a) 99 b) 100 c) 101 2) To what value is big[47] assigned? a) 40 b) 0.47 c) 7 d) 470 3) What is the range of indexes for the big array? a) big[1] to big[100] b) big[0] to big[99] c) big[0] to big[100] d) big[0] to big[9] 4) To what value is maximum assigned? a) 99 b) 100 c) 10 d) 9

ECE2049-E17 Lecture 6 4 Data Representatioins (HW #1): >> Integer representations: --Unsigned, sign-magnitude, two's complement and packed BCD >> Expect Conversion Between Bases and Formats! Unsigned integers = all bits used to convey magnitude (whole numbers) For n bits, values run from 0 to 2 n 1 (i.e. N=16, 0 to 65535) 1026 = 00000100 00000010b = 0402h Sign Magnitude integers = n-1 bits used to convey magnitude with most significant bit or MSB used for sign (0 = +, 1 = -). For n bits, values run from -2 (n-1) -1 to 2 (n-1) -1 1026 = 00000100 00000010b = 0402h -1026 = 10000100 00000010b = 8402h ** Has 2 representations of 0 >>> +0 and -0! Two's Complement integers = Common format for signed integers (int). For n bits, values run from -2 (n-1) to 2 (n-1) -1. (i.e. n=16, -32768 to 32767). Used by C. Positive numbers: Same as Unsigned 1026 = 00000100 00000010b = 0402h Negative numbers (ONLY!!): Encode magnitude, Complement each bit, Add 1-15 = 0000 0000 0000 1111 = 15 1111 1111 1111 0000 complement +1 1111 1111 1111 0001 = 0FFF1h = -15 in two's complement Binary Coded Decimal = Each decimal digit expressed in binary nibble 367 = 0000 0011 0110 0111b

ECE2049-E17 Lecture 6 5 Hexidecimal (hex) Numbers: Base 16 -- 1 Hex character represent values from 0 to 15d using digits 0 Fh 158d = 9Eh Conversion between hex and binary is piece of cake! Just convert each hex digit to a binary nibble... 158d =1001 1110b = 9Eh 9 E Or vice versa 2AC4h = 2 A C 4 0011 1010 1100 0100 b Fractional Number representations: Fixed point: Binary radix point assigned a fixed location in byte (or word) 0101.1010 = 5 + 2-1 + 2-3 = 5.625 Precision is function of number of fractional bits assigned --> 4 fractional bits = 2^(-4) = 0.0625 = smallest fraction Floating Point (IEEE Standard) : Used to better approximate real valued decimal values to a prescribed number of decimal places Single Precision (32 bits): S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF Quick Questions: Value = (-1) S 2 (E-127) * (1.F) 1) The decimal equivalent of unsigned integer 8002h is a) 32770 b) 65538 c) -2 d) 16386 2) The decimal equivalent of two's complement integer 8002h is a) -2 b) 32770 c) -32766 d) -65538 3) The decimal equivalent of packed BCD integer 8002h is a) -2 b) 32770 c) 8002 d) 2008 4) The decimal equivalent of the 32-bit floating point number 4AA80000h a) 1. 3125E+22 b) 5505024.0 c) -5.5024E6 d) -21.0E-18

ECE2049-E17 Lecture 6 6 Little Endian: The MSP430, like Intel processors, is Little Endian (HW1) -- The lower byte of each 16 bit word is stored first then the higher byte Low Byte, High Byte -- For double words the lower word is stored first then the upper word Ex: How 65340 decimal = 00010004h is stored in memory at address 0400h Little Endian Address Byte Value 02403h 02402h 02401h 02400h 00h 01h 00h 04h...... A memory dump from CCS shows contents of addresses from left to right starting at 02400h 02400h= 04 00 01 00... << Bytes appear out of order when read left to right Big Endian: Many other RISC processors -- The higher byte (big end) of each 16 bit word is stored first then the lower byte BIG Endian Address Byte Value 02403h 02402h 02401h 02400h 04h 00h 01h 00h...... A memory dump from a big endian processor (also left to right) 02400h= 00 01 00 04... << Bytes appear in order when read left to right >> BTW, Network Byte Order = BIG ENDIAN!!!

ECE2049-E17 Lecture 6 7 Microprocessor Systems Architecture: >> General Computing Hardware/Software Hierarchy Applications Operating System = User Interface System SW = Interface to HW HW Layer = CPU, Mem., peripherals >> Gets squashed in an embedded system... Applications Maybe some System SW functions HW Layer = CPU, Mem., peripherals Harvard Architecture Separate memory address spaces (and busses) for code and data ( Better architecture for pipelining instruction fetches) Von Neumann Architecture Single memory address space (and bus) for code & data

ECE2049-E17 Lecture 6 8 >> MSP430x55xx uses Von Neumann architecture >> We're using MSP430F5529 -- 128 KB Flash memory (code) -- 8 KB RAM (data) + 2 kb USB RAM -- LCD controller -- Hardware multiply, UART, and a slew of other peripherals (Timers, ADC, comparator, general digital IO ports...) Memory Organization: >> Memory = group of sequential locations where binary data is stored -- In MSP430, a memory location holds 1 byte -- Each byte has unique address which CPU uses to read to and write from that location -- Multibyte data is stored Little Endian! -- 2 types of memory: Volatile and Non-volatile RAM = 8KB = DATA memory = Volatile MSP430 is 16 bit Microcontroller >>Read and Write = retrieving or writing DATA to/from RAM (under programmer control) FLASH = 128KB = CODE memory (primarily!) = Non-volatile >> Fetch = retrieving of instruction from CODE (Flash) memory (automatic CPU function) >> Flash is NOT byte write writable! -- Must be erased in multi-byte (e.g. 512 byte) segments >> Write cycle takes much longer than read cycle >> 16 bit word size = 16 bit internal registers >> Also has 20 bit address bus (can access up to 1 MB = 2 20 addresses) >> Know Memory Map for MSP430x5529x Processors (from HW) -- Addresses for RAM & FLASH, (good thing to have in notes!) >> Know how to figure memory addresses

ECE2049-E17 Lecture 6 9 Quick Questions: 1) The long int i=0x00081230 is stored in memory by a microprocessor as Address 0213h 0212h 0211h 0210h Contents 30h 12h 08h 00h The microprocessor must be a) Little Endian b) Big Endian c) Running Linux d) Running WinXP SP3 2) In the MSP430F5529, the RAM is a) non-volatile system memory b) volatile data memory c) non-volatile code memory d) consists only of the 16 CPU registers 3) In the MSP430F5529, the FLASH memory is a) non-volatile code memory b) volatile data memory c) volatile code memory d) not available in this model 4) The starting addresses for RAM Sector 0 and Code Memory (Flash) respectively are a) 00000h and 02400h b) 00200h and 01100h c) 02400h and 04400h

ECE2049-E17 Lecture 6 10 MSP430F5529 Basic Digital I/O (HW2): >> Eight independent, individually configurable digital I/O ports -- Ports 1-7 are 8-bit wide and Port 8 is 3 bits wide >> Each pin of each port can be configured individually as an input or an output >> Each pin of each port can be individually read or written to Function Select Register: Sets function of each pin in the port (i.e. P4SEL) -- Bit = 0 = Selected for Digital I/O -- Bit = 1 = Not selected for digital I/O (multiplexed pin functions) Direction Register: Sets direction of each pin in the port (i.e. P2DIR) -- Bit = 0 = Corresponding pin is an Input -- Bit = 1 = Corresponding pin is an Output Input Register: Where input to the port is read from (i.e. P2IN) -- Bit = 0 = Logic low -- Bit = 1 = Logic high Output Register: Where data to be output from the port is written (i.e. P5OUT) -- Bit = 0 = Logic low -- Bit = 1 = Logic high Drive Strength: Sets drive strength of port (we will usually leave as default) --Bit = 0 = reduced drive strength (default) --Bit = 1 = full drive strength Pull-up/down Resistor Enable: Enable internal pull resistors (we will use with --Bit = 0 = Not enabled (default) buttons) --Bit = 1 = Enabled (see User's Guide) >> All I/O port registers are memory mapped. Register names defined in msp430x4xx.h (Read from and Write to defined names as if writing to C variables...)

ECE2049-E17 Lecture 6 11 Be familiar with operation of functions from demo project from Lab 0! >> The configuring and using the LEDs, buttons etc. (I'll provide code if needed) >> Polling: Repeated checking of IO ports to see if they have data or need servicing (usually inside main loop) #include "msp430.h" #include <stdlib.h> void configport() P5SEL = 0x00; P5DIR = (BIT7 BIT5 BIT3 BIT1); } void inout() unsigned char in, out; in = P5IN; out = (in & 0x55) << 1; P5OUT = out; } void main() while (1) configport(); inout; } } a) Which port(s) and which pins are being used as digital inputs? b) Which port(s) and which pins are being used as digital outputs? c) Assume that the port 5 input register holds the value 6Dh. What value is written to the port 5 output register?