MSP430 Interrupt Driven Input Design - 30865

Request Posted by


Rating : No Rating
Earned: $0
Request Detail
Price: $15
  • From: Computer Science, Programming
  • Due on: Mon 11 Nov, 2013 (03:05pm)
  • Asked on: Mon 11 Nov, 2013
  • Due date has passed, but you can still Post Solution.

MSP430 Interrupt Driven Input Design
In this lab, you will be designing an assembly program running on MSP430 hardware using the IAR
Kickstart IDE tool, a free tool for IAR for programming MSP430. You will learn interrupt driven
input, and polling designs in terms of a program that takes a user input and toggles an LED.
Moreover, you will find that the lab is designed in a way different from its predecessors, in that
no actual partial code is given. Instead, you will get the clues from program descriptions and
algorithms. I intentionally do this because you will learn to design a program from a problem
statement, which is closer to a real-world case. By doing so, you will have more freedom in your
implementation. This lab worksheet along with your assembly program design and simulation will be
inspected by the instructor in the lab for grading. Note that you will be using your own MSP430 for
this lab. Most of the materials are hosted at

Normally, a computer takes a user’s input, processes the data, and output results. In order for the
computer to handle the user inputs, an I/O interface is typically designed to handle data coming
from the users and flowing out to a display (monitor) or LEDs. We have learnt the output ports in
MSP430 by setting the I/O direction to be the output mode. In this lab, we will exercise the input
mode for the I/O port. The I/O ports in MSP430 are bi-directional.

There are two types of input design: polling and interrupt driven. When a CPU is checking whether
an input button is depressed sporadically, this mechanism is called polling. When the input button
is depressed and the CPU is checking, the input will be taken. By the way, the push button
represents one bit of data, either 0 or 1. For example, we may design an algorithm that lights up
an LED if the input button is depressed (i.e., 0); otherwise, the LED is off. Obviously, the
polling input is not very reliable! For example, what if the button is depressed but the CPU is NOT
checking? The input data would have been lost.

A reliable design is interrupt driven. When the input button is depressed, an I/O interrupt is
generated, and the CPU will be notified to handle the input data. In this scenario, the CPU is
passively notified when there is an input. Most of the time, the CPU is doing its job. If there is
an interrupt for input, the CPU is interrupted and the input will be taken care of. Not only the
interrupt driven I/O is reliable, but also it is more efficient than polling. The reason is because
CPU would have to spend some time for polling the input status periodically.

MSP430 I/O Settings

We will set output mode for the P1.0 (connected to LED), and set input mode for the push button
(P1.2). Because you need to access the physical I/O pins, you may open the plastic cover for your
MSP430 hardware. However, there is no push button on EZ430-F2013. A workaround is that you can use
a paper clip (metal) to touch P4 (i.e., P1.2 port) to function like a push button because your body
is grounded. Alternatively, if you have a push button, just connect it to P4 and P14 (GND). For
P1.2 to work correctly, you also need to set its pull-up

Steps for the main program
1.   Stop watchdog timer
2.   Set P1.0 output mode for LED, and P1.2 for input mode (push button)
3.   Set P1.2 interrupt enable for user input
4.   Clear P1 interrupt flag (remember that the interrupt flag must be cleared by ISR!)
5.   Set P1.2 pull-up resistor
6.   Stop CPU in low power mode 0 and enable global interrupt, waiting for interrupts
In IAR, create a new assembly project named
“InterruptDrivenInput”, write, compile, and run your assembly program.
To take care of the P1.2 inputs, we need to design an ISR for it. All 8 bits for P1 share an
interrupt flag (P1IFG). Each bit is corresponding to an I/O pin. If an interrupt is generated by
the P1.2, the 2nd bit of P1IFG will be 1. Any of the bits requesting for inputs will activate the
ISR. Therefore, we have to make sure if an interrupt if really generated by p1.2 in the ISR. The
following gives the steps of the ISR algorithm.
Steps for the ISR of P1.2
1.   check if the interrupt is requested by P1.2
2.   If yes, toggle the LED and clear the interrupt flag

Implement the ISR and run your assembly program. Push the P1.2 button or use a paper clip to test
the input function.

1 Solution for MSP430 Interrupt Driven Input Design
Title Price Category solution By purchased  
MSP430 Interrupt Driven Input Design
$15.00 no category vomms 0 time(s)
Please Login or Register to Submit the Solution for the Request