Skip to main content
Graduate II
January 1, 2024
Question

Core Hardware Register availability for User

  • January 1, 2024
  • 2 replies
  • 4098 views

Any Core Hardware Register available to user which is not used by HAL or the Processor itself which I can safely use without disturbing the rest of the MCU?

I am using an STM32L431. To keep the System State in check I am using a Volatile uint32_t variable and doing bit manipulations and using it as a 32 Bit Register.


I have to check or update this variable at MHz rate and I was wondering if I can use a "Free" Hardware register of the core to speed things up.


I have to keep track of multiple bits, even in Interrupts. I know a faster processor is the best answer but I am currently stuck with this processor for the prototype and I am almost have full utilization of the Core and desperately need any Bit of Performance available.


I initially thought of using only HAL but to get some more performance I made faster (unsafe) versions of functions and optimized everything I can as per my skills allow.

I think that if I use a Hardware Register, then, the processor does not have to fetch and load anything into its working registers. I am happy if I save 1 or 2 clock cycles.

Edit: I am using CubeIDE and HAL

    This topic has been closed for replies.

    2 replies

    Graduate II
    January 1, 2024

    Review ARM ABI

    R9 often available, used to describe data section.

    Could code in assembler and manage register usage directly. 

    Super User
    January 1, 2024

    You might try the -ffixed-reg argument (for GCC) to prevent compiler from using a specific register.

    https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html