EmbeddedRelated.com
Forums
Memfault Beyond the Launch

How interrrupts are handled (works) ? (internally)

Started by visweswara November 9, 2006
Hi,

I have a fundamental question of how interrupts in uC/uPs actually
works? Many tell what happens when interrupts occur , like the program
flow changes from the main program to ISR. But how exactly this happens
without the interference of CPU?

What I understand is interrupt gets the attention of CPU without CPU
keeping watch over Interrupt Signal. How is this done. I hope interrupt
can wake up a CPU(in sleep mode).

I am confused !?! Please help

regards,
Visweswara

read your text book about computer organization.

interrupt can wake up a CPU, but it will take a long time to wake up a
sleeping CPU.

 But how exactly this happens
> without the interference of CPU?
you should say "without the interference of program". visweswara wrote:
> Hi, > > I have a fundamental question of how interrupts in uC/uPs actually > works? Many tell what happens when interrupts occur , like the program > flow changes from the main program to ISR. But how exactly this happens > without the interference of CPU? > > What I understand is interrupt gets the attention of CPU without CPU > keeping watch over Interrupt Signal. How is this done. I hope interrupt > can wake up a CPU(in sleep mode). > > I am confused !?! Please help > > regards, > Visweswara
visweswara wrote:

> What I understand is interrupt gets the attention of CPU without CPU > keeping watch over Interrupt Signal. How is this done. I hope interrupt > can wake up a CPU(in sleep mode).
The interrupt gets the attention of the CPU without the *software* keeping watch over the interrupt signal. An interrupt is an input pin on the uP. Generally, when the CPU finishes executing the current instruction, it checks the status of the interrupt pin. If an interrupt is pending (active), the internal CPU logic causes the program counter to be loaded with the (appropriate) interrupt service routine address (vector) rather than the next instruction. This is how the software gets control on an interrupt without "watching" for the interrupt. When you're done servicing the interrupt, you return from the interrupt routine and the CPU continues execution at the point it was interrupted. Of course, there are numerous variances, complications, exceptions etc based on the multitude of processors out there - but that's the gist of it. That explanation should get you 4/5 at least!?! Regards, -- Mark McDougall, Engineer Virtual Logic Pty Ltd, <http://www.vl.com.au> 21-25 King St, Rockdale, 2216 Ph: +612-9599-3255 Fax: +612-9599-3266
Mark McDougall wrote:
> An interrupt is an input pin on the uP. Generally, when the CPU finishes > executing the current instruction, it checks the status of the interrupt > pin. If an interrupt is pending (active), the internal CPU logic causes > the program counter to be loaded with the (appropriate) interrupt > service routine address (vector) rather than the next instruction. This > is how the software gets control on an interrupt without "watching" for > the interrupt. >
Mark,Thank you very much for your reply. That means CPU much keep watch over the interrupt pin after every instruction execution ? Then what is the advantage of interrupt over input pin polling. (are they same or diffrent). Regards, Visweswara R
"visweswara" <r.visweswara@gmail.com> wrote in message 
news:1163080527.988265.235410@h48g2000cwc.googlegroups.com...
> > Mark McDougall wrote: >> An interrupt is an input pin on the uP. Generally, when the CPU >> finishes >> executing the current instruction, it checks the status of the >> interrupt >> pin. If an interrupt is pending (active), the internal CPU logic >> causes >> the program counter to be loaded with the (appropriate) interrupt >> service routine address (vector) rather than the next instruction. >> This >> is how the software gets control on an interrupt without "watching" >> for >> the interrupt. >> > > Mark,Thank you very much for your reply. > > That means CPU much keep watch over the interrupt pin after every > instruction execution ? > Then what is the advantage of interrupt over input pin polling. (are > they same or diffrent).
It is polling an input pin but the difference is that it is done in the processor hardware as part of the fetch operation instead of being requested as a software operation. This polling method is fine because it is as fast as it can practically be and means that a currently executing instruction is not corrupted but that the interrupt is spotted before the next instruction is started.
Tom Lucas wrote:
> It is polling an input pin but the difference is that it is done in the >,..
Your answer clears my doubt on interrupts. Thanks for your reply.

Memfault Beyond the Launch