 |
 |
| View previous topic :: View next topic |
| Author |
Message |
kupikupi
Joined: 03 Sep 2005 Posts: 31
|
|
Posted: Sun Sep 04, 2005 3:38 am |
|
|
thanx Ttelmah... very clear explanation ... so i get that the ISR sets a flag when a new command comes in ... and the main function will check whether the ISR has set the flag.. i read somewhere that when there is an interrupt.. execution jumps to the ISR( does it just mean that it checks if the flag is set??) so the ISR does not do anything more than just setting the flag when a new instruction comes in ?? from the codes below:
| Code: | main() {
restart_wdt(); // if you're using the watchdog, reset it here
if (data_avail) {
data_avail = FALSE; // think about it, if the ISR sets it to be true, but
// you never set it to be false, what would happen?
decode_command(); // write a function to decode the command. The
// little code snippet you just posted would do the trick |
if (data_avail) ---> checks if the flag is set
data_avail = FALSE-----> if set then reset the flag and execute the instruction if the new command(but where do i place the instruction for the new command?),if not, continue to the next command.
thanx for the reply...
[/b] |
|
 |
kupikupi
Joined: 03 Sep 2005 Posts: 31
|
|
Posted: Sun Sep 04, 2005 3:40 am |
|
|
thanx Ttelmah... very clear explanation ... so i get that the ISR sets a flag when a new command comes in ... and the main function will check whether the ISR has set the flag.. i read somewhere that when there is an interrupt.. execution jumps to the ISR( does it just mean that it checks if the flag is set??) so the ISR does not do anything more than just setting the flag when a new instruction comes in ?? from the codes below:
| Code: | main() {
restart_wdt(); // if you're using the watchdog, reset it here
if (data_avail) {
data_avail = FALSE; // think about it, if the ISR sets it to be true, but
// you never set it to be false, what would happen?
decode_command(); // write a function to decode the command. The
// little code snippet you just posted would do the trick |
if (data_avail) ---> checks if the flag is set
data_avail = FALSE-----> if set then reset the flag and execute the instruction if the new command(but where do i place the instruction for the new command?),if not, continue to the next command.
thanx for the reply...
[/b] |
|
 |
Ttelmah Guest
|
|
Posted: Sun Sep 04, 2005 6:01 am |
|
|
There are two very different types of 'flag' involved here. There is a _hardware_ flag set by the interrupt 'event'. It is this that actually triggers the ISR to be called. An ISR is called, when the global interrupts are enabled, It's interrupt enable is active, and it's hardware flag gets set. The hardware interrupt 'flag', is the doorbell. If you imagine that the doorbell stays ringing, till you walk through to the front of the house and reset it, then you will get the idea of how this hardware flag works. The interrupt service routine clears this flag automatically when the code exits (this behaviour can be turned off, but only if you know what you are doing). The key though is that once the hardware event happens, this flag will stay active, _till_ the handler is called. This is how you can have multiple interrupts, since an interrupt cannot (normally...) interrupt another interrupt (since the global interrupt enable is automatically turned off inside the interrupt handler), but when the first interrupt is handled, and the code returns, because the flag for the second event is still set, it's handler is then called (this is like having a number of bells in a hotel, where several bells can occur more or less together, but little 'lights' come up to show who has paged the desk. The person answering clears each one, as they are dealt with.
Now as I said before, the ISR itself, can do anything. It is just a program. It _may_ elect to set a flag to say that the event has happened and been handled (the 'sticky note'), or it may just handle the event silently, and leave no sign that it has been called.
Best Wishes |
|
 |
newguy
Joined: 24 Jun 2004 Posts: 1946
|
|
Posted: Sun Sep 04, 2005 11:52 am |
|
|
| Since you're using an IR remote, have a look in the code library for something I posted last December or January. I think it's titled "IR remote control grabber s/w". I used an external interrupt to detect the individual bits coming in from the remote, and when 64 bits had been decoded, then a flag is set so that the main routine can extract & display the data. It will help you to see what we're talking about, and it will also help you with the IR part. |
|
 |
kupikupi
Joined: 03 Sep 2005 Posts: 31
|
|
Posted: Sun Sep 04, 2005 6:43 pm |
|
|
| newguy wrote: | | Since you're using an IR remote, have a look in the code library for something I posted last December or January. I think it's titled "IR remote control grabber s/w". I used an external interrupt to detect the individual bits coming in from the remote, and when 64 bits had been decoded, then a flag is set so that the main routine can extract & display the data. It will help you to see what we're talking about, and it will also help you with the IR part. |
thanx new guy ..i'm going thru it now ... |
|
 |
|
|
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
|