This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FPU divide by 0 and High Current Consumption

I was trying to track down high, approx. 6mA, processor current consumption and I have found high current consumption if the FPU executes a divide by 0. If I comment out the line the current consumption goes down to tens of micro amps. If the line is executed then the current is high since the processor is constantly coming out of sleep.

How does the the SDK deal with a divide by 0 with the FPU? I thought this was a hard fault?

Thanks

Parents
  • By default an FPU divide by zero doesn't do anything, you can set flags in the System Control Block to make it execute a Usage fault (which escalates to a hardfault if you don't have a handler); in this way it's much like the unaligned access on the M3/M4, it only faults if you ask it to.

    I see nothing in the startup file which enables those flags, so it most likely just sets the divide by zero flag in the FPU (which is sticky) and returns zero.

Reply
  • By default an FPU divide by zero doesn't do anything, you can set flags in the System Control Block to make it execute a Usage fault (which escalates to a hardfault if you don't have a handler); in this way it's much like the unaligned access on the M3/M4, it only faults if you ask it to.

    I see nothing in the startup file which enables those flags, so it most likely just sets the divide by zero flag in the FPU (which is sticky) and returns zero.

Children
No Data
Related