Forums

Why ISR contains no arguments and return type is void

Started by sudheervemana August 24, 2004
HI all,

          Can any one clear me why cant we pass the arguments to an
ISR and also why the ISR returns nothing.

With Regards,
Sudheervemana.
sudheervemana <sudheervemana@hotmail.com> wrote:
> HI all,
> Can any one clear me why cant we pass the arguments to an > ISR and also why the ISR returns nothing.
Because "we" don't call the ISR --- the CPU does that by itself, and it has no arguments in hand to pass in, nor would it know what to with a result value, if there were one. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
sudheervemana wrote:
> HI all, > > Can any one clear me why cant we pass the arguments to an > ISR and also why the ISR returns nothing. >
I'm curious. What arguments would you want to pass to an ISR? And where would the returned thing go? Keep in mind that generally (except on some CPUs, where 'software triggered' interrupts are used for OS calls) you have no control exactly when an interrupt would occur. It doesn't make sense to pass it things, or have things returned. Al
In article <972038f9.0408240156.3fc81007@posting.google.com>,
 sudheervemana@hotmail.com (sudheervemana) wrote:

> HI all, > > Can any one clear me why cant we pass the arguments to an > ISR and also why the ISR returns nothing. > > With Regards, > Sudheervemana.
The ISR gets called by the CPU in the middle of the running code. The CPU pushes all of the current program's execution information (eg. program counter, stack pointer and others) and then runs the ISR. So there really is no calling code for the ISR...thus nobody to pass arguments or fetch results. Technically I suppose a CPU could pass an argument to an ISR, but I don't know if it would be meaningful at all. Why did you want to? Or are you just curious? If you want to return information from an ISR to your main program, you can set global flags in the ISR. Just make sure nobody else is modifying the global flags when the ISR gets called. You might get an inconsistent state. -- |\/| /| |2 |< mehaase(at)sas(dot)upenn(dot)edu
"sudheervemana" <sudheervemana@hotmail.com> wrote in message
news:972038f9.0408240156.3fc81007@posting.google.com...
> HI all, > > Can any one clear me why cant we pass the arguments to an > ISR and also why the ISR returns nothing.
This is not true of all processors. With some, the parameter passed (by the CPU) is the Interrupt number which you can then use inside the ISR. tim
On 2004-08-24, Al Borowski <al.borowski@EraseThis.gmail.com> wrote:

> I'm curious. What arguments would you want to pass to an ISR? > And where would the returned thing go?
I'm not the OP, but the interrupt number/index/vector/whatever might be handy. That way you could hook the same ISR to multiple interrupts and have it behave slightly differently based on which interrupt caused it. For example, you've got 4 UARTs and the receive processing for all of the is identical (except for which UART you access and which buffer you put data into). Hooking one ISR to all four and then using the "parameter" to determine which UART/buffer-pair to service would be elegent. -- Grant Edwards grante Yow! An air of FRENCH at FRIES permeates my visi.com nostrils!!
Grant Edwards <grante@visi.com> wrote:
> On 2004-08-24, Al Borowski <al.borowski@EraseThis.gmail.com> wrote:
> > I'm curious. What arguments would you want to pass to an ISR? > > And where would the returned thing go?
> I'm not the OP, but the interrupt number/index/vector/whatever > might be handy. That way you could hook the same ISR to > multiple interrupts and have it behave slightly differently > based on which interrupt caused it.
I honestly don't see the big gain between that and 4 micro-ISRs that each do essentially just ACC := {this interrupt's number} jump to commonISR -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
> Can any one clear me why cant we pass the arguments to an > ISR and also why the ISR returns nothing. > > With Regards, > Sudheervemana.
The ISR can't return a value because technically there is no "caller" to the ISR, so it's declared as type void. For this same reason no arguments can be passed to the ISR since there is no caller, no telling where program flow is at the time of the interrupt, etc,,. -Bruce http://www.rentron.com
On 2004-08-24, Hans-Bernhard Broeker <broeker@physik.rwth-aachen.de> wrote:

>> I'm not the OP, but the interrupt number/index/vector/whatever >> might be handy. That way you could hook the same ISR to >> multiple interrupts and have it behave slightly differently >> based on which interrupt caused it. > > I honestly don't see the big gain between that and 4 micro-ISRs > that each do essentially just > > ACC := {this interrupt's number} > jump to commonISR
Not a big gain, but sometimes a few instructions matter. -- Grant Edwards grante Yow! Was my SOY LOAF left at out in th'RAIN? It tastes visi.com REAL GOOD!!
Grant Edwards <grante@visi.com> wrote:

> Not a big gain, but sometimes a few instructions matter.
If they do, then nice style will have to yield to efficiency. On a CPU with individual ISR vectors, you just have to not use the trick I just showed. On a single-ISR platform, you'ld have to start worrying about how to squeeze single instructions out of a multi-way branch statement. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.