<< Chapter < Page Chapter >> Page >

When the end of the ISR is reached the MSP executed a precise set of steps to pick up the execution of the program where it left off before the interrupt occurred. This process takes 5 cycles.

  • The status register and all previous settings pops from the stack. Any alterations to the status register made during the interrupt are wiped away.
  • The program counter pops from the stack and execution continues from where it left off.

Interrupt enable registers

Using interrupts successfully is not as simple as just writing an interrupt service routine and waiting for the event to occur. Because sometimes you do not want to activate every interrupt in the processor at once, the MSP allows you to mask out certain interrupts. When the triggering event first occurs, the processor checks whether the interrupt is enabled before jumping to the interrupt service routine. For most interrupts, the MSP checks the general interrupt enable bit in the status register and the particular interrupt’s enable in the interrupt enable registers. If both of these have been configured to allow the interrupt, then the interrupt flag is set and the processor enters the interrupt service routine.

By default most interrupts are turned off upon reset, to use most peripheral modules you will need to set the enable bits in the interrupt enable registers and turn on the general interrupt enable. Enabling sometimes causes the interrupt flag to be set, so you should consult the User’s guide on the best order to handle the enabling. Usually to properly configure the interrupt, you will also need to have set up the peripheral module in question before enabling the interrupt.

There are three categories of interrupts for the purpose of masking in the MSP430. Reset interrupts, non-maskable non-reset interrupts, and maskable interrupts.

Maskable interrupts are the lowest priority interrupts and can be turned off individually with the various interrupt enable registers or turned off as a group by setting the general interrupt enable bit (GIE) in the status register (SR).

Non-maskable interrupts are not subject to the general interrupt enable (GIE). However each non-maskable interrupt source can be controlled by a bit to specifically turn it on or off. These are the flash access violation interrupt enable (ADDVIE), external NMI interrupt enable (NMIIE), and the oscillator fault interrupt enable (OFIE). All three of these bits are located in the interrupt enable register 1 (IE1).

Reset interrupts have the highest priority and will always reset the execution of the device. The external reset can be configured to trigger either the reset interrupt or an NMI interrupt.

The interrupt enable registers (IE1 and IE2) are used to individually enable the interrupts. Refer to the MSP User’s Guide and Data sheet on the specifics of each peripheral. The example code that accompanies the Rowley system and the Texas Instruments website are also very good sources of example code.

For example, the serial port USART receive interrupt is configured in the example file fet140_uart01_09600.c from Texas Instruments. The serial port interrupts are typical of the maskable peripherals. The procedures followed are drawn from the instructions and notes in the documentation. Often the relevant information may not be in one chapter or section of the guides. This is part of the reason working examples are essential to developing a working knowledge of the processor.

The fet140_uart01_09600.c file begins by turning off the reset activated by the watchdog timer. Then selects the external clock for the ACLK’s source. The example writer assumes a 3.58 MHz clock, but in our case this is a 7.37 MHz clock. This would means that our actual baud rate for this example will be about 19200 baud rather than 9600. The example then executes a do-while loop that waits for the oscillator fault flags to stop being asserted. When an oscillator or crystal first receives power, it often has some instability in its oscillation. The oscillator fault flag detects the instabilities. Because we are planning on using an external clock in the example, it is prudent to wait for the crystal to settle before proceeding.

To support fast operation of the serial port, the example selects the faster external clock for both the CPU and for the UART module. The UART module is also configured to the desired options and baud rate. The details of these settings are found in the UART chapter of the MSP User’s Guide. The serial peripheral supports several different interfaces, so the module enable register ME1 is then used to select UART mode. The interrupt enable for the UART receive is then set. Because the serial port uses general I/O port 3, the special pin use must be selected via the Port 3 mode select (P3SEL). The transmit pin direction must be changed to an output. Finally, the last step is to enable interrupts which sets the general interrupt enable (GIE).

With everything configured, the actual interrupt service routine only needs to process the characters received. The interrupt occurs when a character has been loaded from the serial bus into the receive buffer.

More detailed information on the operation of interrupts can be found in the MSP User’s Guide. Unfortunately the material is generally found in the chapter for each subsystem. The general interrupt information is found in chapter 2.

Questions & Answers

A golfer on a fairway is 70 m away from the green, which sits below the level of the fairway by 20 m. If the golfer hits the ball at an angle of 40° with an initial speed of 20 m/s, how close to the green does she come?
Aislinn Reply
cm
tijani
what is titration
John Reply
what is physics
Siyaka Reply
A mouse of mass 200 g falls 100 m down a vertical mine shaft and lands at the bottom with a speed of 8.0 m/s. During its fall, how much work is done on the mouse by air resistance
Jude Reply
Can you compute that for me. Ty
Jude
what is the dimension formula of energy?
David Reply
what is viscosity?
David
what is inorganic
emma Reply
what is chemistry
Youesf Reply
what is inorganic
emma
Chemistry is a branch of science that deals with the study of matter,it composition,it structure and the changes it undergoes
Adjei
please, I'm a physics student and I need help in physics
Adjanou
chemistry could also be understood like the sexual attraction/repulsion of the male and female elements. the reaction varies depending on the energy differences of each given gender. + masculine -female.
Pedro
A ball is thrown straight up.it passes a 2.0m high window 7.50 m off the ground on it path up and takes 1.30 s to go past the window.what was the ball initial velocity
Krampah Reply
2. A sled plus passenger with total mass 50 kg is pulled 20 m across the snow (0.20) at constant velocity by a force directed 25° above the horizontal. Calculate (a) the work of the applied force, (b) the work of friction, and (c) the total work.
Sahid Reply
you have been hired as an espert witness in a court case involving an automobile accident. the accident involved car A of mass 1500kg which crashed into stationary car B of mass 1100kg. the driver of car A applied his brakes 15 m before he skidded and crashed into car B. after the collision, car A s
Samuel Reply
can someone explain to me, an ignorant high school student, why the trend of the graph doesn't follow the fact that the higher frequency a sound wave is, the more power it is, hence, making me think the phons output would follow this general trend?
Joseph Reply
Nevermind i just realied that the graph is the phons output for a person with normal hearing and not just the phons output of the sound waves power, I should read the entire thing next time
Joseph
Follow up question, does anyone know where I can find a graph that accuretly depicts the actual relative "power" output of sound over its frequency instead of just humans hearing
Joseph
"Generation of electrical energy from sound energy | IEEE Conference Publication | IEEE Xplore" ***ieeexplore.ieee.org/document/7150687?reload=true
Ryan
what's motion
Maurice Reply
what are the types of wave
Maurice
answer
Magreth
progressive wave
Magreth
hello friend how are you
Muhammad Reply
fine, how about you?
Mohammed
hi
Mujahid
A string is 3.00 m long with a mass of 5.00 g. The string is held taut with a tension of 500.00 N applied to the string. A pulse is sent down the string. How long does it take the pulse to travel the 3.00 m of the string?
yasuo Reply
Who can show me the full solution in this problem?
Reofrir Reply
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