Getting Started

(lily) #1

Chapter 7: Microcontroller Interrupts and Timers


r Interrupts and


o microcontroller applications, but they have
ing language. I can’t think of a good way to
y mix in these topics so we will stop with the
dware. Interrupts and timers will be helpful in
re useful.

know These things are machine dependent
and sp will apply to other microcontroller
milie amily and specifically for the ATmega169.


We usu ds in microcontroller software to check to see if
an event has occurred: polling and interrupts. Polling occurs when a section of
de, u ain(), looks to see if an event has occurred. For
stanc ue or false),
d if
signe to interrupt the program, then we don’t have to
ll th ftware so that when the pin state we are
0v, an interrupt function will be called.


a you’d pick up the
and your caller would shriek, “I’ve
r! Why don’t you check your phone every five minutes
, but
some know
out i

crocontrollers respond to interrupts much like you would. Maybe you are
gs. You use you fingernail to scratch a mark next

Chapter 7: Microcontrolle


Timers


Interrupts and Timers are critical t
nothing to do with the C programm
progressively discuss C and smoothl
C for a while and look at our har
making later projects mo


C s nothing about interrupts or timers.
ecific. While the general concepts
fa s, the specifics are for the AVR f


Interrupts


ally use one of two metho

co
in


sually an infinite loop in m
e, it may check pin 6 to see if the voltage is +3 or 0 (logic tr
an +3 do one thing and if 0 do another. If the microcontroller hardware is
de d so that pin 6 can be used
po e pin, we can set up the so
interested in, say falling from +3v to


Interrupts are much like interrupts in daily life. The telephone, for instance,
interrupts your activities by its insistent ringing. But imagine how it would be if
you h d to poll the telephone to receive calls. Periodically,
receiver and say ‘Hello, anybody out there?’
been waiting for an hou
like a normal person?” The ringing interrupting workflow might be annoying
if one is calling you to tell you that your garage is on fire, you want to
ab t immediately.


Mi
reading a book and the phone rin

Free download pdf