DSPRelated.com
Forums

C++ function as interrupt function

Started by Streitwieser Johann June 28, 2002
Hello,

I have a C++ function "void foo(void);".
If a user software interrupt [SFT0I] occure this function should run.

By other compiler I have the keyword "interrupt". How do I define the C++
function in VisualDSP++ ?

The function name in assember is "_foo__Fv". How do I call the C++ function
in the interrupt table ?

I don't find a trap command to trigger the software interrupt. In C I find
the command "raise()" but how do I trigger the "user software interrupt 0"
in assembler ?

Thank's for any help

DR. JOHANNES HEIDENHAIN GmbH

Dipl. Ing. Johann Streitwieser

--------------------
<mailto:>
Tel +49 / 8669 / 31-1773
Fax +49 / 8669 / 32-1773
----------------
DR. JOHANNES HEIDENHAIN GmbH
Dr.-Johannes-Heidenhain-Str. 5
83301 Traunreut
Deutschland

<http://www.heidenhain.de/




--- In adsp@y..., Streitwieser Johann <streitwieser@h...> wrote:
> Hello,
>
> I have a C++ function "void foo(void);".
> If a user software interrupt [SFT0I] occure this function should
run.
>
> By other compiler I have the keyword "interrupt". How do I define
the C++
> function in VisualDSP++ ?

Why is it any different - 'interrupt' wasn't a keyword. It was a
library function that took care of connecting your function to the
interrupt table so that when the interrupt occured, your software
branches to this function.
You should be able to use this in VisualDSP++ just like in earlier
versions. Read the C Compiler guide for VisualDSP++ and look
under 'interrupt' in the library section - it gives you details of
actual syntax, header files, etc.

Cheers
Bhaskar

> The function name in assember is "_foo__Fv". How do I call the C++
function
> in the interrupt table ?
>
> I don't find a trap command to trigger the software interrupt. In C
I find
> the command "raise()" but how do I trigger the "user software
interrupt 0"
> in assembler ?
>
> Thank's for any help
>
> DR. JOHANNES HEIDENHAIN GmbH
>
> Dipl. Ing. Johann Streitwieser
>
> --------------------
> <mailto:streitwieser@h...>
> Tel +49 / 8669 / 31-1773
> Fax +49 / 8669 / 32-1773
> ----------------
> DR. JOHANNES HEIDENHAIN GmbH
> Dr.-Johannes-Heidenhain-Str. 5
> 83301 Traunreut
> Deutschland
>
> <http://www.heidenhain.de/>


On Thu, 2002-06-27 at 23:16, Streitwieser Johann wrote:
> Hello,
>
> I have a C++ function "void foo(void);".
> If a user software interrupt [SFT0I] occure this function should run.
>
> By other compiler I have the keyword "interrupt". How do I define the C++
> function in VisualDSP++ ?

The function must have the signature "void f(int)". You don't need to
use the parameter, but you need to declare it. Just don't name it if you
don't use it. The runtime machinery passes the interrupt identifier (ie.
the signal.h constant) here.

> The function name in assember is "_foo__Fv". How do I call the C++ function
> in the interrupt table ?

Register it with one of the interrupt() family of API's. If the function
is to be used as a "one-shot" (masked after each use), use one of the
signal() family of API's to register it.

> I don't find a trap command to trigger the software interrupt. In C I find
> the command "raise()" but how do I trigger the "user software interrupt 0"
> in assembler ?

I haven't done this, but I think raise() should do the job.


There is a very nice article in the Embedded Systems Magazine on unsung
C/C++ as interrupt service routines. I f you look on their web page, I al
certain you will find it useful. Just to add my two cents, it is not much
different that setting up an ISR in the older DOS operating system
environment. You do need a good understanding of the hardware internals (a
given if you are building embedded code) and some insight into the compiler
(not as trivial with these ADSP tools. None the less, if you have done it
in DOS it will be just as trivial in the DSP world, once you get around the
ADSP tools. I have done it for the Motorola 68K DSP and, as I said, the
tolls and compiler were the biggest stumbling block.

Best of luck.

Jos