Skip to main content
Associate II
May 9, 2025
Solved

Floating-point arithmetic interrupts

  • May 9, 2025
  • 2 replies
  • 681 views

Hello to everyone in the forum.

 

I am using STM32H735.

Is it possible to perform a floating point number operation and generate an interrupt when an exception occurs?

I want to interrupt when the bit for exception generation in the FPSCR register is turned ON.

Or do I have to create a thread for register monitoring and constantly check the bits?

 

I await your advice.
See you soon.

This topic has been closed for replies.
Best answer by mƎALLEm

Hello,

Normally FPU interrupt handler FPU_IRQHandler() is intended to be used for this kind of check.

So enable the FPU NVIC and try to trigger one of the conditions that sets one of the flags in this register:

Floating-Point Status and Control Register, FPSCR

 

 

2 replies

mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
May 9, 2025

Hello,

Normally FPU interrupt handler FPU_IRQHandler() is intended to be used for this kind of check.

So enable the FPU NVIC and try to trigger one of the conditions that sets one of the flags in this register:

Floating-Point Status and Control Register, FPSCR

 

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Hey0256Author
Associate II
May 10, 2025

Dear mƎALLEm , thank you for your reply.

I took your advice and added an interrupt process.
The interrupt process was called after the floating point division by zero.

I would like to add more processes as we continue to investigate this.

Again, thank you very much.

#define FPU_DZC_MASK 0x02
void FPU_IRQHandler(void)
{
 uint32_t *fpscr = (uint32_t *)(FPU -> FPCAR + 0x40);
 (void)__get_FPSCR();

 *fpscr = *fpscr & ~(FPU_DZC_MASK);
}
 NVIC_SetPriority(FPU_IRQn, 5);
 NVIC_EnableIRQ(FPU_IRQn);
 float a = 1.0 / 0;