ST


A world leader in providing the semiconductor solutions that make a positive contribution to people’s lives, both today and in the future.

Automatic clock configuration

Clock source selection is done thanks to the CLOCK_SOURCE define mask value: USE_PLL_HSE_EXTC|USE_PLL_HSE_XTAL|USE_PLL_HSI|USE_PLL_MSI

  • USE_PLL_HSE_EXTC : the system clock is using an external clock (PLL + HSE_BYPASS used). On ST board, this external clock is often provided by the MCO coming from the ST Link (8 MHz clock).
  • USE_PLL_HSE_XTAL : the system clock is using an external xtal (PLL + HSE_ON used). On NUCLEO board, this xtal should be soldered on X3.

Note that default parameters are set with a 8 MHz clock. If the xtal value is different:

- the SDK code must be changed to adapt the different clock dividers and PLL setting (system_clock.c file)

- HSE_VALUE has to be redefined in targets.json file, adding a config value for the target. Ex:

"config": { "hse_value": { "value": "24000000", "macro_name": "HSE_VALUE" }

  • USE_PLL_HSI : the system clock is using the high speed internal clock
  • USE_PLL_MSI : the system clock is using the multi speed internal clock (only available in STM32L4 family)

If several values are set in the mask, STM32 SDK tries to configure the clock in this order:

1. USE_PLL_HSE_EXTC:

2. USE_PLL_HSE_XTAL

3. USE_PLL_HSI

4. USE_PLL_MSI

Note that :

  • HSE_BYPASS and HSE_ON (USE_PLL_HSE_EXTC and USE_PLL_HSE_XTAL) are exclusive: you should not select both value in the mask.

Clock source selection default mask value is set in targets.json file. Here is an example:

        "config": {
            "clock_source": {
                "help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
                "value": "USE_PLL_HSE_EXTC|USE_PLL_HSI",
                "macro_name": "CLOCK_SOURCE"
                }
        }

This can be overwritten in mbed_app.json file depending on your application or target. Here is an example:

  "target_overrides": { 
        "NUCLEO_F070RB": {
               "target.clock_source": "USE_PLL_HSI"
               }
        }

NB: ST is providing a graphical software configuration tool that allows the generation of C initialization code using graphical wizards, and in particular a clock-tree setting helper:

http://www.st.com/en/development-tools/stm32cubemx.html


See the mbed-cli documentation for more information on the configuration system syntax:
https://os.mbed.com/docs/latest/tools/adding-and-configuring-targets.html


All wikipages