sample_exam1_A09_sol

sample_exam1_A09_sol - Name: ECE Box: ECE2801 Sample EXAM...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Name: ECE Box: ECE2801 Sample EXAM #1 Show all work. Be sure to sign your test and any scrap paper. Circle final answer for each part of each question. Points are as indicated. Good Luck! 1) Encode or decode the following numbers in the indicated formats. (30 pts) IEEE 32—bit Floating Point format is shown below: 8 EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF Where V = (—1)S * 2(E'127) * 1.FFF... a. Encode 19.125 in 32—bit floating point format. Express final answer in hex. » - i: \> ‘ 2 ' if i...) O l o o o u o x x {3‘ i i i“; Dwm4i;.- « “a. M M ’ “1m \) ‘ a” W l 4’ "f c.) J J v i ,WW‘“NN // 0 o 4) f ( LI- 1 A} [i 0 fi/ Now give the decimal equivalent value of 8028b assuming the following formats b. 2-byte Two's Complement Integer c. 2-byte Unsigned Integer d. 2-byte Sign—magnitude Integer e. Binary coded decimal (BCD) f. 2 ASCII characters (one character per byte) (u 2 gm i) a [5000 (1)000 @010 10:} a; \L'fla/ l +3 l y. "mmuw-wfl'e‘ “ m .V W n - 12m w ‘;‘ l I o . 1; er 2) In a “memory dump” from a certain microprocessor the memory locations are shown incrementally from left to right starting with the address given at the left. For example, this line shows the contents of memory (in hex) from address 0400h to 040Fh with address O400h holding 00 and address 040Fh holding 15h. Ex: 0XO400 00 04 00 9A 00 AF 0C C1 23 55 24 6D 00 00 15 Below is a memory dump showing how the following variables are stored in memory at one point during program execution. The variables are stored sequentially beginning at address 0500h. (20 pts) unsigned ii = 0; // 16 bit unsigned int char mask1, mask2=15; long int qual = Ox71FA8081; // 32 bit 2's complement char myString[4];- W2 w 0x0500 00 00 AA OF 71 FA 80 81 48 45 4C 50 00 11 45 54 f—Mfi— 0X051O 10 00 80 00 00 00 01 02 00 FF 71 00 70 F8 F8 00 0x0520 11 45 54 0011 00 5481 80 0011 A0 CCOQ 7622 a) Is this microprocessor a Little Endian or Big Endian? How can you tell? I?“ k I i i mi :0)‘ i 'A 0"i i; S‘be'dbiin “tit! mmm, 8"; “m” ‘0“? "‘i it 7 F id a L/ c n “An (hykiyu 7iian"invcwmrni b) What ASCII text is stored in myString? (\Qfl{%“ > \\ ’I 4;} 4;: at? 5‘0 22:? HELP c) What value is stored in the variable mask1? AA (1) At what address is the variable mask2 stored? axoéi e) Show how these 5 variables would be stored in memory on the MSP43OC449. Assume the starting address is 0300h. 0x0300 00 00 AA op g. 80 "FA 7: gig 45 46 5‘0 void writeWord(const char *word); // displays words up to 7 // chars on MSP430 LCD int newThing(int num1, num2); // prototype for new function void main() { int newNum, IastSave = 0, myNum; unsigned char inKey, led; LEDOff(); setupKeypadO; initLCD(); inKey = 0; while (ALL_GOOD) // o r'evv’évr m k' { if ((inKey >= ASCII_0) && (inKey <= ASC|I_9)) { newNum = inKey-ASCI|_O; //1ai<1 w VW “E 'W key Vite/D‘A- myNum = newThing(newNum,lastSave); if (myNum > O) { IastSave=newNum; // Migvl‘ 1:3 W“ T" W £9535” Mum‘ke” clearLCD(); writeWord(inKey); stelay(5); clearLCD(); writeWord("BlGGEST"); steIay(5); inKey = O; , // 9&6?- m r: “TLJLAiytwki‘flfl‘i-hg / LEDOffO; .3 ism»: w“ ,a |ed=inKey&0x0F' // «2mm in in W {W L“) “WW? Ho“ 1 ' I J'7"‘T.r‘ ’ *‘g LEDdisplayHex(ied); J; §Pi£tgiify<i 1‘ else { clearLCD(); writeWord("ENTER #"); steIay(5); inKey = myGetKeySOJ if ((inKey == '*') || (inKey == '#')) {buzzerOn(); ' w . .- r ‘ ‘5: SWDelay“); // 9 Wart (){Aafig ii) film HAIL/f 6h 0 b mien); , buzzerOffO; m0 {‘fi steIay(1); buzzerOn(); steIay(1); buzzerOff(); clearLCD(); writeWord("NOT A #"); steIay(5); // 20f [‘v-Aré inKey = 0; “ } 1. J }// end while }// end main() /***** Function newThing() ******/ // WHAT DOES THIS FUNCTION DO? // _ _ u , ' " // my,“ W W Z'rénfx‘ Mwm WV M 17 arm-MW” fl’m" int newThing(int thing1, thingZ) { newVal = thing1-thingZ; return(newVaI); } if LCD LEDs Buzzer 1 b) mm W «2T7 0% C) ATM” #3 0 Ofi crrhir P ' M“ A 4* 75% wine ~7 5x . , «- % {0 U “E e) B l 5:16; i; .5» ? : .-‘ M n Y (Ty-y 4) The single red LED on the Olimex board is connected to Port 1 pin 3 as shown below. (25 pts) 3-3 V o MSP430 V E: P1.3 a) Using the code framework below, complete the function red LE D() which will properly configure and light the red LED or turn it off based on the value of its input argument. Your function should not alter the settings of any other Port 1 pins. b) Complete the function inFromP5() to properly configure P5.7—0 all as digital inputs and to read in a byte from Port 5. c) In main() will the LED light when testByte is odd or even? /* Compiler directives (includes and defines) */ #include "msp430x44x.h" #include <stdlib.h> void redLED(unsigned char on_off) {/l LED is lights when on_off = 0 and is off otherwise Pl WE l: 917:3: flwr Pig 7;) ampsaff P’ 5“ 9* f "“ Wig: l 5“ Pl; 5 org/w 2/0 :4: (wwfl :2: o) ’l PIDHT (fl 2 ‘ 3145/ _ new l= an; ) } unsigned char inFromP5() { P; WM = 0WD ‘/ /( gH P3" 7~o TA I‘APW p5” 95L NW; 11 m— p); 7» r- aw‘w 1/9 f 3; V P (4 M? f? i g» 3N)/ } void main() { while (1) { unsigned char testByte, tmp; testByte = inFromP5(); tmp = testByte & 0x01; redLED(tmp): steIay(3); } } \ _ ~ ‘ * J‘Héw" Wm WWW w m“. MALEW") M' w C 6“ Rad L I6.“ I "T U‘P ...
View Full Document

This note was uploaded on 10/12/2009 for the course ECE 2801 taught by Professor Jarvis during the Spring '08 term at WPI.

Page1 / 8

sample_exam1_A09_sol - Name: ECE Box: ECE2801 Sample EXAM...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online