stm32cortex-mfpu

Division by zero exception flag not set in STM32H7 FPU


I'm digging into the FPU of a STM32H743 (Nucleo board, Keil IDE).

I've checked that the FPU is enabled in register CPACR.

I've compiled the following dumb code:

volatile double test = 0;
test = 1.0 / test;

If I look at the assembly I've got:

VDIV.F64 d0,d1,d0

where d1 contains the double representation for 1, d0 contains the double representation for 0.

After the instruction d0 contains 0x7F00...00 which is a representation for infinity, so it looks fine.

However the flag DZC in register FPSCR is not set, as I was expecting it would be.

Am I missing something ?


Solution

  • The issue is in the debugger.

    Reading the FPSCR from the code (with instruction VMRS) works fine. But through the debugger (System Viewer FPU tab) of Keil 5.28 the value is wrong.

    I've been told there is the same issue with gdb.

    EDIT: since I am back on FPU exception management, I noticed I was wrong in my previous answer. The Cortex M7 Programming Manual explicitely states that:

    The FPSCR register is not memory-mapped, it can bee accessed using the VMSR and VMRS instructions

    So it is not a debugger issue.