You wish to interface a white LED to the MSP430. The data sheet indicates that the LED has a forward voltage drop VF = 2.4V and a forward current IF = 20mA. Draw the circuit diagram such that the LED is illuminated when P1.0 of the MSP430 outputs a logic-0.
Calculate the value of the current-limiting resistor.
The following C code polls an active-low push-button to determine when it is pressed, then toggles and LED, and finally polls the button again to determine when it is released.
Rewrite this code in assembly language for the MSP430. Do not debounce the button.
void poll_button()
{
while (P1IN & BIT1);
P1OUT ^= BIT0;
whilie (!(P1IN & BIT1));
}
ECE 447 – Single-chip Microcomputers page 2 of 11 Dr. Craig Lorie
Example Midterm Problems Fall 2016
For each assembly language instruction given below, identify the source operand addressing mode and the destination operand addressing mode. Assume that symbols and memory have been properly defined/allocated elsewhere in the code.
Addressing modes:
The first entry in the table is provided as an example.
Instruction opS opD amS amD Function
mov #55, R12 IM R R12 ← #55
mov 2(R10), 16(R12)
add #25, 8(R9)
mov @R10, R11
mov R11, dest
mov R11, &dest
sub R13, R14
bic #0x81, R5
and @R6, R7
and R6, R7
addc R8, &dest
ECE 447 – Single-chip Microcomputers page 3 of 11 Dr. Craig Lorie
Example Midterm Problems Fall 2016
(a) mov R6, 4(R5)
Registers: Before: Registers: After:
R5 0x3456 R5
R6 0x789A R6
Memory: Before: Memory: After:
0x3456 0x15EE 0x3456
0x3458 0xC0C0 0x3458
0x345A 0xD15C 0x345A
0x789A 0x1ABA 0x789A
0x789C 0xDABA 0x789C
0x789E 0xD000 0x789E
(b) mov @R5+, R6
Registers: Before: Registers: After:
R5 0x3456 R5
R6 0x789A R6
Memory: Before: Memory: After:
0x3456 0x15EE 0x3456
0x3458 0xC0C0 0x3458
0x345A 0xD15C 0x345A
0x789A 0x1ABA 0x789A
0x789C 0xDABA 0x789C
0x789E 0xD000 0x789E
ECE 447 – Single-chip Microcomputers page 4 of 11 Dr. Craig Lorie
Example Midterm Problems Fall 2016
The voltage curve for an active-low push-button is given in the figure below. Please modify
the figure as follows:
(a) Indicate at which point(s) in time the button bounces by adding
at the appropriate place(s) in the figure.
(b) You want to use a Port interrupt to detect button presses and a Timer to wait for the button
to stop bouncing. Indicate, using arrows, the time(s) at which the Port will generate
interrupts and the time(s) at which the Timer will generate interrupts. Identify the
interrupt source associated with each arrow, and number the arrows sequentially.
(c) Describe for each arrow, the primary function that must be performed by the associated
interrupt service routine (e.g. start timer, decode, key, etc.)
ECE 447 – Single-chip Microcomputers page 5 of 11 Dr. Craig Lorie
bouncing
period
key released key pressed key released
Example Midterm Problems Fall 2016
Write a C program that configures Timer_A to output the signals to control two active-high
LED’s according to the following specifications:
read from PORT3. The value should be interpreted as an unsigned number, and any
value greater than 100 should be treated as 100 (i.e. the maximum value is 100).
Interrupts must be used to detect a change on PORT3.
Note: P1.1, P1.2, and P1.3, can be used to output TACCR0, TACCR1, and TACCR2,
respectfully. The most elegant solution will have the LEDs controlled directly by the timer.
ECE 447 – Single-chip Microcomputers page 6 of 11 Dr. Craig Lorie
Example Midterm Problems Fall 2016
The MSP430 on the $13 MSP Launchpad has 8 pins on PORT1 (P1.0 – P1.7), but only 6 pins
on PORT2 (P2.0 – P2.5). Despite this, you would like to connect four 7-Segment displays
(each with 8 LEDs and a common anode (+) ) and one 16-button keypad.
Below is a list of parts that you may use in your design. Draw the circuit diagram.
74HCT245 Octal buffer, bidirectional i.e. if direction DIR=0, A=B; if DIR=1, B=A
74HCT244 Dual Quad buffers with a separate OE for each Quad buffer, unidirectional
74HCT373 Octal Latches, if latch enable LE=1, Q=D; if LE=0, Q=Q0
74HCT374 Octal Flip-Flops (i.e. 8-bit register). FFs trigger on rising clock edge.
All devices have active-low output enable (OE). When inactive, the outputs of the devices
are in the high-impedance state.
ECE 447 – Single-chip Microcomputers page 7 of 11 Dr. Craig Lorie
Example Midterm Problems Fall 2016
You wish to interface an inexpensive ultrasound sensor to the MSP430 to measure distance.
The sensor has a single output pin, and produces a pulse of length proportional to the distance
measured. It’s behavior is linear. It can measure distances from 1 foot to 50 feet, and outputs
a pulse length of 1 ms per foot (e.g. it outputs a pulse length of 18 ms for a distance of 18 ft).
Write a C program that uses the ultrasound sensor to measure the distance. Store the value for
the measured distance in a variable named distance.
Note: P1.1, P1.2, and P1.3 are connected to CCI0A, CCI1A, and CCI2A, respectfully.
In addition to writing the C program, please answer the following questions:
(a) Which clock are you using for Timer_A?
(b) What is the maximum pulse-length that can be measured by Timer_A? When answering
this question, ignore the “50 feet” maximum distance specification given above.
(c) What is the resolution (or precision) of the measurement using this clock?
ECE 447 – Single-chip Microcomputers page 8 of 11 Dr. Craig Lorie
Example Midterm Problems Fall 2016
Memory – Info B to the block of RAM starting at address 0x1C00.
For more information about the memory map, see the MSP430FR6989 data sheet, section 6.13.
The following are the specifications for the program:
ECE 447 – Single-chip Microcomputers page 9 of 11 Dr. Craig Lorie
Example Midterm Problems Fall 2016
between the rising-edge and falling-edge of the input signal.
Use TimerA0. Assume that the input is connected to input CCI1A.
Given below are the specifications for the hardware and the software.
◦ scan the keypad to determine which key was pressed
◦ store the value of the pressed key in a global variable
◦ set a “data ready” flag to indicate that a new key has been pressed.
ECE 447 – Single-chip Microcomputers page 10 of 11 Dr. Craig Lorie
Example Midterm Problems Fall 2016
(b) What is the addressable memory space of the MSP430X (in bytes)?
(c) How many bits are in a data word on the MSP430?
How many of these are special-purpose registers?
(b) What is the function of the PC, SP, and SR?
(c) Briefly define each bit in the Status Register (SR).
the order in which the interrupts will be serviced?