Page 24 - Embedded Microprocessor Systems Real World Design
P. 24
Many designers overuse interrupts. An interrupt does just that-it interrupts
program execution. Interrupts are best used for those things that cannot wait for
the processor to get to them. In some cases, an interrupt can be used just to reduce
the hardware complexity (and the associated costs), but almost always it is at the
expense of increased debug time and higher potential for hard-to-find intermittent
errors. In those cases where interrupts are required, it is important to know how
many really are needed. Interrupts are used to not3 the processor of special events
such as a timer that timed out or a piece of hardware that needs attention. Count-
ing the events that need interrupts is straightforward, but be sure to take into
account internal interrupt sources as well. Some tricks can be played to reduce the
number of interrupt signals required when there are more interrupt smrces than
the processor has interrupt inputs. Again, we’ll discuss these in Chapter 5.
Real- Time Considerations
This subject covers a lot of territory and is closely connected to the issue of pro-
cessing speed. Real-time events are what embedded microprocessors generally are
intended to handle. However, some specific events deserve special consideration.
For example, you might have a subsystem that controls a motor using pulse-width
modulation. In this scheme, the motor current is controlled by switching the
current at a very high rate and using the duty cycle to control the motor speed.
The motor, being a relatively slow mechanical device, responds to the time-
average of the current (see Figure 1.2). Lowerduty cycles result in lower average
current and slower rotation. (This is a very high-level description; entire books
have been written about PWM and motor control. Read one of those for all the
details.)
In our hypothetical motorcontrol system, say that the microprocessor cannot
keep up with the motor on a real-time basis. That is, the choppingrate, the rate at
which the motor current is switched on and off, is faster than the microprocessor
can handle. But the other required tasks, such as communicating with whatever is
controlling the motor-processor subsystem, are no problem for our processor. It
V v- ~
During this interval. the device is on half the time and off During this interval. the device is on 75% d tha thm and olf
haif the tkne It responds ea ifn wm being drlven wlth 25% ofthe the ll responds (u1 Ifk wm teina drlven wilh
a DC w#aQe of hall ofthe Supply voltage a DC vdlaoe equal lo 75% of the suppb voilqte
Figure 1.2
PWM Operation.
System Design 9