Timer, Interrupt, Exception in ARM: Modifications From Prabal Dutta
Timer, Interrupt, Exception in ARM: Modifications From Prabal Dutta
University of Michigan
Interrupts
Merriam-Webster:
to break the uniformity or continuity of
Interrupts
Interrupt (a.k.a. exception or trap):
An event that causes the CPU to stop executing the current
program and begin executing a special piece of code called an
interrupt handler or interrupt service routine (ISR).
Typically, the ISR does some work and then resumes the
interrupted program.
Interrupts are really glorified procedure calls, except that they:
can occur between any two instructions
are transparent to the running program (usually)
are not explicitly requested by the program (typically)
call a procedure at an address determined by the type of
interrupt, not the program
External device
Reset button
Timer expires
Power failure
System error
Names:
interrupt, external interrupt
How it works
Something tells the processor core there is an
interrupt
Core transfers control to code that needs to be
executed
Said code returns to old program
Much harder than it looks.
Why?
is in the details
How do you figure out where to branch to?
How to you ensure that you can get back to
where you started?
Dont we have a pipeline? What about partially
executed instructions?
What if we get an interrupt while we are
processing our interrupt?
What if we are in a critical section?
Where
Snazzy architectures
Nested interrupts
Ignore it
But what if it is important?
Prioritize
Take those interrupts you care about. Ignore the
rest
Still have dedicated register problems.
Critical section
We probably need to ignore some interrupts but
take others.
Probably should be sure our code cant cause an
exception.
Use same prioritization as before.
1) No power
2) System is held in RESET as long as VCC15 < 0.8V
a) In reset: registers forced to default
b) RC-Osc begins to oscillate
c) MSS_CCC drives RC-Osc/4 into FCLK
d) PORESET_N is held low
15
Pending interrupts
17
In this case, the processor never took the interrupt because we cleared the
IPS by hand (via a memory-mapped I/O register)
18
19
20
21
22
23
24
25
26
27
28
29
30
Interrupt handlers
31
32
Communication
Media Access Control (MAC) protocols
Modulation
Navigation
GPS
http://www.youtube.com/watch?v=SOESSCXGhFo
Resonating element/Driver:
Quartz crystal can be made to
resonate due to Piezoelectric effect.
Resonate frequency depends on
length, thickness, and angle of cut.
Issues: Very stable (<100ppm) but not
all frequencies possible.
MEMS Resonator
Arbitrary frequency, potentially cheap,
susceptible to temperature variations.
Others:
Inverter Ring, LC/RC circuits, Atomic
clock, and many more.
Clock Driver
http://www.actel.com/documents/SmartFusion_MSS_UG.pdf
Features of Timers
a.k.a. terms you need to know
Who cares?
There are two basic activities one wants
timers for:
Measure how long something takes
Capture
Example #1 -- Capture
FAN
Say you have a fan spinning and you want to know
how fast it is spinning. One way to do that is to have
it throw an interrupt every time it completes a
rotation.
Right idea, but might take a while to process the interrupt,
heavily loaded system might see slower fan than actually
exists.
This could be bad.
Example #2 -- Compare
Driving a DC motor via PWM.
Motors turn at a speed determined by the
voltage applied.
Doing this in analog land can be hard.
Need to get analog out of our processor
Need to amplify signal in a linear way (op-amp?)
Virtual timers
You never have enough timers.
Never.
Virtual Timers
Simple idea.
Maybe we have 10 events we might want to
generate.
Just make a list of them and set the timer to go off
for the first one.
Do that first task, change the timer to interrupt for the
next task.
Problems?
Only works for compare timer uses.
Will result in slower ISR response time
May not care, could just schedule sooner
Implementation issues
Shared user-space/ISR data structure.
Insertion happens at least some of the time in user
code.
Deletion happens in ISR.
We need critical section (disable interrupt)
Implementation issues
(continued)
What data structure?
Data needs be sorted
Inserting one thing at a time