Skip to content Skip to navigation Skip to collection information

OpenStax_CNX

You are here: Home » Content » Microcontroller and Embedded Systems Laboratory » Lab 5: Interrupts

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • TI MSP430 display tagshide tags

    This module and collection are included inLens: Texas Instruments MSP430
    By: Texas Instruments

    Comments:

    "Basic introduction to microcontroller-based embedded systems development. Includes structured laboratory exercises in the following areas: assembly programming, C language programming, peripheral […]"

    "This lab discussed interrupts and how to implement them."

    Click the "TI MSP430" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Lab 5: Interrupts

Module by: adrian valenzuela. E-mail the author

Summary: Lab 5 will discuss what interrupts are for and how to fire them.

Exercise 1

Seven Segment Counter

Write a function, void seg_count(int num), similar to the LED counting function, led_num(), from Lab 4. In this case, the function will display a number between 0 and 15 on the seven-segment display in hex.

The pin-outs for the blue MSP430F16x Lite Development Board are configurable through a programmable PLD. This allows the user to change the pin map in software. You can see the current arrangement of the pins here: LiteBoardPinout

Using the seg_count() function you just wrote. Write a program that does the following:

  • Poll for button_1 being pushed. Begin counting up slowly on the seven-segment display. It must be slow enough that it can be human readable. Counting will pause if button_1 is pushed again.
  • Poll for button_2 being pushed. If it is pushed, begin counting in the opposite direction. Initially, the counter will go up from 0 to F.
  • If the counter is going up and it reaches its maximum value, it will roll over to zero and continue counting. If it is counting down it will roll over to its maximum value.
  • Be sure to include all appropriate header files, disable the Watchdog Timer, and initialize the master clock.

Exercise 2

Firing an Interrupt

Interrupts, as the name implies, will interrupt a program whenever it is, and when the interrupt is done being serviced it will jump back to wherever it was in the program. This allows the programmer to have more freedom in their code, automates certain functions, and reduces the number of checks handled by the processor.

In order to fire an interrupt, the following must be done:

  • All interrupts on the processor are disabled by default and must be first enabled globally.
  • Next, each specific interrupts must be enabled.
  • Finally, for each enabled interrupt, an interrupt service routine (ISR), the interrupt handler, must be written. Once an interrupt fires, the program will jump to this section of the program.

A typical program using interrupts will look like the following piece of code:


    void  main(void){      
      _EINT();            //Enables interrupts globally
      //... more code
    }

    void SOME_interrupt (void) __interrupt[SOME_vector]{
      //...more code that runs once interrupt fires
      return;
    }
        
Processors are designed to be able to service interrupts from predefined, specific places. The list of possible interrupts is put into an interrupt vector, and each must be enabled individually. To find the name of the interrupt vector that needs to be enabled, check the MSP430Fx16x.h header file's Interrupt Vectors section.

Write an interrupt that will fire when the buttons are pushed. If you need additional help, there are examples in the ../Crossworks MSP430 1.x/samples/ directory.

Modify the program from Problem 1 so that it is interrupt based and does not poll for the buttons being pushed. How does your program behavior changes? When would you want to use polling over using an interrupt?

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks