Skip to main content
zabel
Associate III
March 30, 2016
Question

Standard library: stm32xxx_rcc.c: waste of RAM?

  • March 30, 2016
  • 1 reply
  • 711 views
Posted on March 30, 2016 at 18:25

Hi,

I am looking how to save a few bytes in RAM. I am using the standard peripheral lib, and included in stm32f10x_rcc.c, stm32f2xx_rcc.c and stm32l1xx_rcc.c, I found some static constant arrays (PLLMulTable, APBAHBPrescTable, ADCPrescTable) which are only used to lookup some constants. Now these arrays are declared ''static __I'', __I is a preprocessor symbol defined as ''const volatile''. This leads to locating the arrays in RAM. Is there any reason for this? I think, it would save some bytes in RAM if these arrays would just be declared as ''static const'', because in this case the toolchain just locates them into the text segment in Flash memory. Or am I missing something?

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    March 31, 2016
    Posted on March 31, 2016 at 08:38

    There is certainly a lot of crap going on there. When I port to a board I tend to clean up the PLL settings, SystemCoreClock, and move that table as a static const into the one routine that actually uses it. Perhaps there were other uses back in the day.

    Porting usually involves setting an application appropriate stack and heap too.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..