ST suggests using their XLS configurators that generate system_stm32xxxx.c file for you.

This generator can be found on http://st.com site if you need one for STM32L1xx the family you can use this one:

STM32L1xx_Clock_Configuration_V1.2.0.xls

You need Microsoft Excel. I use 2003, because had some issues with newer versions. Also, you need to enable Lower Macros level in Excel settings for making this work. Then you should open the file:

Frequency configurator for STM32

Some advice:

  • Don't edit PLLVCO manually, for some reason xls allows it but you should not. Change PLLMUL instead
  • If you need bigger frequencies change Vcore for bigger value.
  • Press generate and file system_stm32l1xx.c will be created near .xls file. Delate .c file manually before generating it again.

Example generated config by settings used on the screenshot: system_stm32l1xx.c

For additional info read en.CD00290434.pdf