• AVR Freaks

Hot!A few comments on PIC32MZ math exceptions

Junior Member
  • Total Posts : 97
  • Reward points : 0
  • Joined: 2012/12/24 10:12:06
  • Location: 0
  • Status: offline
2019/03/18 10:57:44 (permalink)
4.5 (2)

A few comments on PIC32MZ math exceptions

At the risk of sounding like an advertisement, the PIC32MZ really is an amazing microcontroller!  I'm using its floating point unit, and it's blazingly fast.  I'm developing a C (non-Harmony) application, and was initially concerned about getting possible divide-by-zero errors.  But the PIC32MZ automatically recognizes and propagates NaNs and +/-Infinity floating point results, flawlessly and transparently.

I haven't seen this documented anywhere, but with the PIC32MZ you don't need to modify the startup code, you don't need to write a _general_exception_handler() function to examine the CPU's (exception) "Cause" register, and you don't have to worry about how to recover from math errors.  If you do get a math error, the IEEE 754-2008's "quiet NaN" (or [+/-]Infinity) simply propagates through all subsequent operations that use that value.  This makes for a robust design, and it's saving me a lot of time and trouble.  Thanks Microchip!


1 Reply Related Threads

    Super Member
    • Total Posts : 250
    • Reward points : 0
    • Joined: 2016/03/11 22:47:59
    • Location: 0
    • Status: offline
    Re: A few comments on PIC32MZ math exceptions 2019/03/23 11:52:10 (permalink)
    Yes it does work very well, all thanks to the proper implementation of IEEE754 math. A wonderful article I ran across explains IEEE754 in very easy to understand detail.
    "What every computer scientist should know about floating-point arithmetic" by: D. Goldberg, 1991
    The paper is readily found with a Google search.
    Jump to:
    © 2019 APG vNext Commercial Version 4.5