2016-03-30 09:25 AM
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?2016-03-30 11:38 PM
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.