cancel
Showing results for 
Search instead for 
Did you mean: 

Using FPU in ISR and main() Code

pranjalk197
Associate II

I want to use the FPU in an ISR. Will I have context switching issues or i have to specifically make changes in the System_stmxx.c if i am using code generated from CubeIDE.

Do i need to setup these registers explicitly or it is handled by CubeIDE by default? (i didn't found these bits explicitly setup in System_stmxxx.c )

 FPU->FPCCR |= (FPU_FPCCR_ASPEN_Msk | FPU_FPCCR_LSPEN_Msk);
This code sets the ASPEN (Automatic State Preservation Enable) and LSPEN (Lazy State Preservation Enable) bits, ensuring that the FPU context is handled appropriately during interrupts.

MCU: STM32H723ZGT6
CubeIDE Ver: 1.16.0
1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Those two bits are set by default, so no explicit setup is needed.

There are no other issues or special considerations you need to make to get this to work. When the first FPU instruction is used within an ISR, the FPU registers are pushed onto the stack. This is handled by the core. You'll lose some cpu cycles due to this, but the program will function as intended.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

1 REPLY 1
TDK
Guru

Those two bits are set by default, so no explicit setup is needed.

There are no other issues or special considerations you need to make to get this to work. When the first FPU instruction is used within an ISR, the FPU registers are pushed onto the stack. This is handled by the core. You'll lose some cpu cycles due to this, but the program will function as intended.

If you feel a post has answered your question, please click "Accept as Solution".