CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

why we needs interrupts

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

why we needs interrupts
PostPosted: Sun Jan 01, 2012 1:09 pm     Reply with quote

What is the main purpose of the interrupts? When and why we use them? Help me to be a bit more advanced ;) Thx.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Sun Jan 01, 2012 1:43 pm     Reply with quote

Interrupts
A possible way to visualize this is as follows.
You live in a busy house and you hear the door bell ring. Your only options are to stop what you are doing and answer it or finish what you are doing and hope the visitor is still there. Now the pic without interrupts is like the second option. It doesn't take care of the door bell. It at best can be put in a loop where it periodically opens the door to see if any one is there. With certain things like RS232 which is asynchronous the second approach is vulnerable to missing characters. However with an interrupt any part of the code including say half way through executing any line of code the bell will ring and the interrupt can answer the door and invite the visitor into a parlor so you (the code) can get to it later. The visitor is never missed.
Ttelmah



Joined: 11 Mar 2010
Posts: 19497

View user's profile Send private message

PostPosted: Sun Jan 01, 2012 1:47 pm     Reply with quote

Then (of course) comes the second part.
_If_ you need to keep on doing the job you were working on when the bell went, you must just answer the door, take the package and get rid of the caller as soon as possible. If you stand and chat on the doorstep, vital things that you were doing when the bell went, can/will go wrong.
This is why the interrupt handler should (in 99% of cases) _just_ do the essential jobs that the bell signals need doing, and nothing else.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 01, 2012 5:40 pm     Reply with quote

Here's another example that I use. Suppose you are waiting for the mail
to be delivered to your mailbox, which is out near the street. When the
mailman picks up your outgoing mail and delivers new mail, he will flip
down the red flag on the mailbox.

So every 30 minutes, all day long, you look out your window to see if the
red flag is down, which means the mail has come in. This is called "polling".

But what if you had a switch and a buzzer connected to the mailbox, and
it went into your house. Then when the buzzer makes a sound, you know
the mail is in, and you can go get it. That is called an "interrupt".

The interrupt is better (in this case), because it saves you the time of
having to look out the window every few minutes to check the mailbox.
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

Re
PostPosted: Mon Jan 02, 2012 2:28 am     Reply with quote

Thank you very much Guys(guess)! I'm a self learning boy whit another profession. Unfortunately,there is no much information about CCS programming at internet on my vernacular (Bulgarian). I'm glad to see, that there is people ready to help me at that initial degree.




Best wishes!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group