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.

Interfacing the MSP430 to an LED.

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.

Polling a Push-button

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

MSP430 Addressing Modes

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:

R = Register, IX = Indexed, S = Symbolic, A = Absolute,

IN = Indirect, INA = Indirect Autoincrement, IM = Immediate

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

Complete the tables, below, for the given mov instructions

(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

Key Debouncing

The voltage curve for an active-low push-button is given in the figure below. 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

Timer_A Compare Mode

Write a C program that configures Timer_A to output the signals to control two active-high

LED’s according to the following specifications:

LED1 should blink at a frequency of 2 Hz, with a duty cycle of 50%.

LED2 should blink at the same frequency, but with a duty cycle determined by the value 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).

As soon as the value on PORT3 changes the duty cycle for LED2 should be adjusted.

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

Multiplexing General Purpose I/O Ports

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

Timer_A Capture Mode

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

Write a C program to transfer 64 bytes of data from the top (i.e. lowest address) of Information

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.

Write a C program that updates a 4-bit output each time the push-button is pressed.

The following are the specifications for the program:

Configure bits 4 – 7 of P1 as outputs.

Configure bit 0 of P1 as an input.

Configure the internal resistor on P1.0 to be a “pull-up” resistor.

Assume that the push-button is connected to P1.0.

The push-button causes an interrupt to the processor when it is pressed (falling edge).

Initialize the output on P1.4 – P1.7 to 0000.

The value output on P1.4 – P1.7 should be incremented on each button press.

The output value should roll-over from 1111 to 0000.

Use interrupts and an interrupt service routine.

Put the MSP430 in the appropriate low-power mode when waiting for a button press.

Button debouncing is not necessary in this code.

ECE 447 – Single-chip Microcomputers page 9 of 11 Dr. Craig Lorie

Example Midterm Problems Fall 2016

Write a C program to compute the pulse width of an input signal. That is, measure the time between the rising-edge and falling-edge of the input signal.

Use TimerA0. Assume that the input is connected to input CCI1A.

Write a C program to use the MSP430 to scan a 4×4 keypad.

Given below are the specifications for the hardware and the software.

Use Port P1.

Put the MSP430 in the proper low-power mode.

Use interrupts to detect a key press.

Write an interrupt service routine (ISR) to

◦ 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.

Ignore key debouncing.

ECE 447 – Single-chip Microcomputers page 10 of 11 Dr. Craig Lorie

Example Midterm Problems Fall 2016

How wide is the MSP430 data bus?

How wide is the MSP430 address bus?

How many address bits are needed to access 128 KBytes of memory?

How much memory can be accessed using a 16-bit address bus?

(a) What is the addressable memory space of the MSP430 (in bytes)?

(b) What is the addressable memory space of the MSP430X (in bytes)?

(c) How many bits are in a data word on the MSP430?

(a) How many registers are included in the MSP430 Register Set?

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).

What is the difference between maskable and nonmaskable interrupts?

Write an assembly language instruction to set the Global Interrupt Enable (GIE) bit.

When more than one maskable interrupt occurs simultaneously, how does the MSP430 decide the order in which the interrupts will be serviced?

 

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.
Scroll to top