









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










E C E 41 7 5 Q U IZ 2-13 -08 2 o f 2
C onsider the possib le consequences of not stopping the counting of T imer3 and also of reloading (rather than adding into) T M R 3 H :T M R 3 L. Assum e that it takes a maxim um of three cycles of the C PU after T imer3 rolls over and before the CP U has fetched the instruction at the high-priority interrupt vector address 0 x0008 and is ready to execute it. a. C ross out the instruction above that stops the co unting of T im er3 and the instruction that starts the co unting of T imer3 again. b. H ow m any C P U clock cycles can occur after T im er3 rolls over and b efore the ab ove co de will have reloaded T M R 3 H :T M R 3 L with the content of S T E P C N T H :S T E P C N T L? In answering this, to the left of each line above that is executed until T M R 3 H :T M R 3 L has been reloaded, write the number of cycles executed for that line. Cycles = 12 c. H ow m any microseco nds will pass after T im er3 rolls over until T im er3 is incremented again by the 32.768 kH z watch crystal? Microseconds = 30. d. G iven this, will reloading T imer3 rather than stopping T imer3 and adding into it always work? E xplain your answer b riefly. Yes; we are assured that Timer3 will not be reloading at the same time that it is counting.
Show the code you would use to do this, making use of the L o a d L C D S T R IN G macro. LoadLCDSTRING("NEW DATA "); Display();
E C E 41 7 5 Q U IZ 3-26 -08 1 o f 2 H igh 113 SIX PR O B LEM S U pper quarter 87 O pen book, open notes M edian 68 Lower quarter 58 I added 10 points to everyone’s grade. Low 35
[1 5% ] to the P C. a. If you had left IN T O SC = 4 M H z, ho w long wo uld it have taken to transmit the five bytes? Each byte, including its start and stop bits, takes 10/19200 seconds, or 10000000/19200 microseconds. This computes to 521 microseconds, or about 0.5 millisecond. Five bytes thus take about 2.5 ms. b. W ith IN T O SC = 1 M H z, ho w long does it take to transmit the five bytes? The same 2.5 ms. c. W hy does d ecreasing IN T O SC from 4 M H z to 1 M H z while send ing these five bytes to the P C decrease the average current draw on the coin cell? Because in either case there is a 2.5 ms time interval during which the chip draws a current determined by the clock rate. That current is about 1 mA for INTOSC = 4 MHz and about 0.5 mA for INTOSC = 1 MHz. (See Figure 2-4)
E C E 41 7 5 Q U IZ 3-26 -08 2 o f 2
a. For the serial peripheral interface, how are these two problems handled?
The MCU designates the specific device that is to receive and act upon the multiple-byte message by making that device’s chip enable pin active. Usually the chip enable pin is active low, so this means that the MCU pin that drives that chip enable pin has a zero written to it.
The MCU precedes the sending of the multiple-byte message with the activation of the specific device’s chip enable pin. It terminates the message by deactivating that device’s chip enable pin. Furthermore, because it is enabled, the SSPIF flag will be set after each received byte.
b. For the I C interface (a.k.a. the SM B us), how are these two problems handled?^2
The MCU indicates that a multiple-byte message is about to begin by transitioning the SDA and SCL lines through the I C^2 START condition. That is, the MCU first pulls the SDA line low and then the SCL line low (from their initial state of both being high). The end of the multiple-byte message is indicated when the MCU causes the SCL line to go high followed by the SDA line going high — a change that is called the I C^2 STOP condition.
Each device on the I2C bus has its own unique seven-bit address. Seven bits of the first byte of the multiple-byte message hold this seven-bit address. The addressed device responds to the rest of the message. All other devices on the bus ignore the rest of the message.
is being transduced is related to M by the equation [20% ] N = 4.321M + 342 a. R eexpress this relationship to avoid floating-po int math as well as division, so as to m inimize co m putation time while maintaining 1 p art in 20 48 resolution. Multiply 4.321M by X/X, where X is a power of 256 so that the division by X can be achieved by moving the numerator to the right by one byte position for 256 or two byte positions for 256x256. To maintain 1 part in 2048 resolution, X = 256 is not sufficient whereas X = 256x256 = 65536 is. So N = (65536/65536) x 4.321 x M + or N = 283181M/65536 + b. E xpress the computation in C. Y ou can assum e that M has been defined as a four-byte “long” variable. N = ((283181 * M)>>16) +342; If the C compiler implements this with bit shifts rather than byte moves, use the following instead. N = (((283181 * M) >> 8) >> 8) +342; Michael Pribble and John Hamilton had this answer. Many students used N = ((8849 * M) >> 11; to get the 1 part in 2048 resolution. However this doesn’t minimize the computation.
EC E 4175A Final 4-29-08 Page 1 of 3 H igh 116 SEV EN PR O B LEM S U pper quarter 95 O pen book, open notes M edian 79 Lower quarter 68 Low 51
b. T o the right of each of the five lines above, list your estimate of the num ber o f micro seconds taken to execute that line. c. If the M C U draws 1.000 mA while executing instructions with a clock rate of 1 M H z, then determine the average current draw of the M C U contributed by this five-line sequence when it is executed every ten m illiseconds, assuming that the M C U sleeps when it is done doing useful work each loop tim e. Show all your work clearly. Iawake = 1000 :A x ((3xSUM)+2)/10000 = 0.1((3xSUM)+2):A. 5 :A
E C E 4175A Final 4-29-08 P age 2 of 3
toggle the least-significant bit of a char variable, P A R IT Y F L A G , if bit 3 of P O R T B is read as a zero. Show that line of program code here: PARITYFLAG ^= 0x01;
(leaving the other b its of P O R T D unchanged) if P A R IT Y F L A G equals zero during the interrupt call when the fifth of each group of five bits occurs. Show the code here: if (!PARITYFLAG) { PORTDbits.RD4 = 1; }
P O R T D (leaving the other bits of P O R T D unchanged) when the swipe of a new card is begun, as detected by the first time bit 3 of P O R T B is read as a zero. Show the code here: PORTDbits.RD4 = 0;
[25 % ] the drive for each of the two C O M i lines provide a way to drive the line to 3 V (the M C U supply voltage), 1.5 V , or 0 V. T he backplane waveform s for C O M 1 and C O M 2 are shown in the middle of the page. B elow these two waveforms are shown the four frontplane waveforms to be applied to SEG 1. T he bottom waveform is intended to turn on bo th pixel 11 and pixel 12, the leftmo st two pixels illustrated. T he other three turn one, or the other, or b oth o f these sam e pixels off. a. T he LC D itself draws essentially no current. W hat is the current draw on the coin cell due to the C O M 1 resistor circuit when its voltage is 1.5 V?
b. C an you drive C O M 1 to +3V with no current draw (due to this drive) at all? E xplain your answer. Y e s ; s e t R C 0 = R C 1 = 1 c. C an you drive C O M 1 to 0V with no current draw at all? E xplain your answer. Y e s ; s e t R C 0 = R C 1 = 0 d. A s the C O M 1 and C O M 2 waveforms are continuously driven with a 50 H z frame frequency, determine the average current draw o n the coin cell due to the generation of these waveforms (ignoring the M C U ’s current draw)? Show your work clearly.
e. W hat is the interval needed between interrupts so that the corresponding interrupt service routine can be used to generate these wavefo rm s? 5 m s f. Showing all work, determine the R M S voltage between the frontplane and the backplane for pixel 12 when both p ixel 11 and pixel 12 are off. R M S = /(( (1.5) 2 + (0) 2 + (1.5) 2 + (0) 2 )/ 4) = 1.06V
EC E 4175B Final 4-30-08 Page 1 of 3 H igh 99 FO U R PR O B LEM S U pper quarter 94 O pen book, open notes M edian 83 Lower quarter 68 Low 51
5 x 10 :s = 50 :s
E C E 4175B Final 4-30-08 P age 2 of 3