O'Reilly logo

Microcontroller Programming and Interfacing Texas Instruments MSP430 by Daniel J. Pack, Steven F. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

220 7. RESETS AND INTERRUPTS
operating modes. Typically, while a controller is waiting for a designated event to occur, whether it
is an arrival of a particular external signal or after a programmed elapsed time period, it operates in a
power save mode with all or most of its clocks turned off. When the time comes, the microcontroller
switches the operating mode (wake up from sleep’), perform necessary tasks, and switch back to the
power saving mode until the next designated event occurs. The method to switch back and forth
between operating modes uses the interrupt system, which is the topic of this chapter.
7.2 BACKGROUND
Typical embedded systems operate in environments where electrical and mechanical noises abound.
These noise sources can interfere with the proper function of the microcontroller in an embedded
system, which can appear during the operation of the system as skipping intended instructions
and unintentionally changing the contents of registers. One of the primary means to combat such
malfunctions in the MSP430 microcontroller is the Watchdog Timer System we introduced in
Chapter A.5. By forcing the program to update special registers periodically, one can make sure
that intended instructions are executed in the proper order, and if not, make the controller reset and
resume normal operation. Interrupts are requests whose time of occurrence is not known in advance,
but the programmer can plan to cope with them when they occur. For example, suppose that you
know a user will push an external button to indicate that a task should be finished during the course
of an operation of your MSP430 microcontroller but do not know when it will occur. You can write
a separate program that will respond to the event appropriately. All you need now is to detect when
that event occurs, so that you can ‘run the specially prepared program. There are two ways for a
microcontroller to detect when an event occurs. The first method, called polling, relies on using the
resources of the controller to continuously monitor whether or not the event has occurred. This can
be in the form of checking a flag continuously to see the flag status change (bit changes from 1
to 0, or vice versa) or the change of the logic level on an input pin. The second method, which is
the focus of this chapter, is using the interrupt method. In this approach, the CPU performs other
critical tasks (use resources optimally) or even be turned off to save power and only react to the event
when it occurs. Naturally, the polling method is simple to implement compared to the configuration
required to implement the interrupt method. The benefit, however, of the interrupt method is the
conversation of limited, precious power resources.
7.3 MSP430 RESETS/INTERRUPTS OVERVIEW
In the MSP430 microcontroller, the System Control Module (SYS) governs resets and interrupts.
There are three types of resets in the MSP430: Brownout Resets (BOR), Power-On Resets (POR),
and Power-Up Clear Resets (PUC). For interrupts, we divide them into two categories: Non-
Maskable Interrupts (NMI) or Maskable Interrupts (MI). The three different resets allow the
MSP430 to start at three different start up states, giving the desired flexibility. The non-maskable
interrupts are those that MSP430 controllers cannot or should not ignore, such as the critical power

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required