<< Chapter < Page Chapter >> Page >
Lab 5 will discuss what interrupts are for and how to fire them.

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.

Got questions? Get instant answers now!

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?

Got questions? Get instant answers now!

Questions & Answers

what is phylogeny
Odigie Reply
evolutionary history and relationship of an organism or group of organisms
AI-Robot
ok
Deng
what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Microcontroller and embedded systems laboratory. OpenStax CNX. Feb 11, 2006 Download for free at http://cnx.org/content/col10215/1.29
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Microcontroller and embedded systems laboratory' conversation and receive update notifications?

Ask