interrupt service routine locks with floating point calculat

Hi All: I have a simple interrupt service routine function running with IRQ
10, this function runs at 3200 times/second, it runs fine
until i put in a simple floating point calculation like z = x *y; the whole
PC locks up where x, y, z are all declared as double.

if i change them int, then it is back running fine.

Ran Zhang <rzhang@vamcointernational.com> wrote:

Hi All: I have a simple interrupt service routine function running with IRQ
10, this function runs at 3200 times/second, it runs fine
until i put in a simple floating point calculation like z = x *y; the whole
PC locks up where x, y, z are all declared as double.

if i change them int, then it is back running fine.

Yup. You can’t do floating point operations at interrupt time. Best
bet is fixed point.

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com

If you are willing to in-line a couple of processor instructions you can
stash a copy of the FPU register set while you are using it and then
restore the FPU before finishing your ISR.

The instructions of interest are: fwait, fsave, and frestore.

Evan Hillas wrote:

If you are willing to in-line a couple of processor instructions you can
stash a copy of the FPU register set while you are using it and then
restore the FPU before finishing your ISR.

The instructions of interest are: fwait, fsave, and frestore.

While it’s only a few opcodes (on x86), the time/cost to save the FPU
context is non-trivial, especially in an ISR which is going to execute
at high rates.

Also, not all x86s have a FPU unit, so you’ll have to handle that case
as well.


Cheers,
Adam

QNX Software Systems
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>

“Adam Mallory” <amallory@qnx.com> wrote in message
news:cnb65l$g0s$1@inn.qnx.com

Evan Hillas wrote:
If you are willing to in-line a couple of processor instructions you can
stash a copy of the FPU register set while you are using it and then
restore the FPU before finishing your ISR.

The instructions of interest are: fwait, fsave, and frestore.

While it’s only a few opcodes (on x86), the time/cost to save the FPU
context is non-trivial, especially in an ISR which is going to execute at
high rates.

Yeah I remember reading about that. Each register is 80 bits I beleive and
there are 8 of them, plus the status register. I think restoring involves
some sort of reset of the FPU.

Also, not all x86s have a FPU unit, so you’ll have to handle that case as
well.


Cheers,
Adam

QNX Software Systems
[ > amallory@qnx.com > ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <> pschon@baste.magibox.net

Want long instructions? Try an I/O access.