This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[C6713] Catching floating point exceptions in C

DSP: 6713
CCS: 3.1

My question revolves around using floating point exceptions in C. 
Are there some examples that may show me how trap an FP exception?

Also,  I would like to be able to detect if a floating point
variable is a NaN (Not a Number) or a properly formatted variable. 
We will be using data copied in from an FPGA via the HPI (Host-Post Interface).  This data may
not be formatted in the correct FP format.  I need assistance to determine
if the value can be accessed as a FP variable or if I need to initialize
the value to a default value.

Thanks for any assistance you can offer.



  • You may be able to detect FP overflow after it happens.  The header file c6x.h (found in the \include directory of the compiler distibution) contains definitions for many CPU control registers.  One of them may contain a bit that gets set when FP overflow occurs.  I'm not enough of a CPU expert to know.

    As for detecting NAN's, there is no compiler feature that can assist with that.  Sorry!


  • The 67x/67x+ CPU and Instruction Set Reference Guide spru733 (currently Rev A) has some further details on these status bits.  You should look specifically at the FADCR register for catching issues related to floating point add/subtract.  You should look at the FMCR for information related to floating point multiplies.


  • With regard to finding NAN's ... The header file <math.h> has a macro named isnan(x), which checks for NAN for any floating point type.

    Thanks and regards,