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.

how to handle “divide by zero” on DM6437

Hi all,
I’m working with DM6437 and I faced with following problem:
My project is written in C++ but there are few C files mainly related to peripheral drivers. Now I’d like to catch if “divide by zero” is occurred and to handle it on the proper way. I found in “TMS320C6000 Optimizing Compiler v 6.1” that C64+ support “try-catch” feature but I’m not sure am I allowed to use it even if my project is not implemented in pure C++ code(like I said there are few C files). Is there any other way to check “divide by zero” and to handle it on the proper way?
Note. I’m also using intrinsic and I’m not sure does it change anything.

  • dejan sajic said:
    I found in “TMS320C6000 Optimizing Compiler v 6.1” that C64+ support “try-catch” feature but I’m not sure am I allowed to use it even if my project is not implemented in pure C++ code(like I said there are few C files).

    This is a good question, the SPRU187 document is not entirely clear on that, though it does specifically say that one cannot mix objects that have exceptions enabled with those that do not, so I would try building with the --exceptions option on the C files as well to see if the compiler lets you. My suspicion is that this would work as the run time support library is written in C.

    dejan sajic said:
    Is there any other way to check “divide by zero” and to handle it on the proper way?

    One alternative I have seen suggested in the past was to modify the run time support library divide function itself to check for division by 0 (all the source is in there in a .src file), though it seems the C++ exceptions (which were not always available) is a fine method.

  • Thanks  Bernie,

    I was thinking also to handle it in divide function but I was not sure if there is better (faster) way to do it. Problem is that I’m using IQMath library so I should change IQ divide function but there is no source code for it, just library. [:)]