Dynamic Frequency Scaling

When power management is enabled, the peripheral bus (APB) frequency and CPU frequency may change during operation. This process is called Dynamic Frequency Scaling (DFS). When DFS is enabled, the APB frequency can be changed multiple times within a single RTOS tick. The APB frequency change does not affect the operation of some peripherals, while other peripherals may have issues. For example, Timer Group peripheral timers will keep counting, however, the speed at which they count will change proportionally to the APB frequency. Therefore, developers should understand which peripherals will be affected by DFS and which peripherals will not. With the continuous improvement of ESP-IDF development, more and more peripheral drivers will not be affected by DFS.

The following peripherals are not affected by DFS when clocked from a specific clock source:

  • UART: If REF_TICK is used as the clock source, UART is not affected by DFS. Otherwise, it will be affected by DFS.

  • LEDC: If REF_TICK is used as the clock source, LEDC is not affected by DFS. Otherwise, it will be affected by DFS.

  • RMT: If REF_TICK or XTAL is used as the clock source, RMT is not affected by DFS.

Currently, the following peripheral drivers are not affected by DFS. These drivers will acquire the ESP_PM_APB_FREQ_MAX lock for the duration of the transaction and release the lock upon the completion of the the transaction automatically.

  • SPI host

  • I2C

  • I2S (if an APLL clock is used, I2S acquires ESP_PM_NO_LIGHT_SLEEP power management lock.)

  • SPI slave: between calls to spi_slave_initialize() and spi_slave_free(), SPI slave is not affected by DFS.

  • Wi-Fi: between calls to esp_wifi_start() and esp_wifi_stop(), Wi-Fi is not affected by DFS. In Modem-sleep mode, when Wi-Fi is enabled, the chip releases the ESP_PM_APB_FREQ_MAX power management lock upon turning off the RF module.

  • TWAI: between calls to twai_driver_install() and twai_driver_uninstall(), TWAI is not affected by DFS.

  • Bluetooth: between calls to esp_bt_controller_enable() and esp_bt_controller_disable(), Bluetooth is not affected by DFS. In Modem-sleep mode, when Bluetooth is enabled, the chip releases ESP_PM_APB_FREQ_MAX power management lock upon turning off the RF module, but still holds the ESP_PM_NO_LIGHT_SLEEP power management lock unless CONFIG_BTDM_CTRL_LOW_POWER_CLOCK is configured to the 32 kHz external crystal oscillator.

The following peripheral drivers are affected by DFS, so applications need to acquire or release locks themselves.

  • PCNT
  • Sigma-delta
  • Timer Group