Hi,
did a search but keep getting HTTP ERROR 500, so I ask here.
It there an ESP-IDF API function to get the current CPU frequency?
Thanks
API to get CPU frequency
Re: API to get CPU frequency
you can use the function esp_clk_cpu_freq() to get the current CPU frequency.
This function returns the frequency of the CPU clock in Hz. You can include the header file "esp_clk.h" in your project and call this function to obtain the CPU frequency. Here's an example:
The variable cpu_freq will now contain the current CPU frequency in Hz.
Note that the CPU frequency can vary depending on the power management mode, such as whether the CPU is in sleep mode or active mode. Therefore, you may need to call this function periodically to get an updated value.
This function returns the frequency of the CPU clock in Hz. You can include the header file "esp_clk.h" in your project and call this function to obtain the CPU frequency. Here's an example:
Code: Select all
#include "esp_clk.h"
// ...
uint32_t cpu_freq = esp_clk_cpu_freq();
Note that the CPU frequency can vary depending on the power management mode, such as whether the CPU is in sleep mode or active mode. Therefore, you may need to call this function periodically to get an updated value.
Re: API to get CPU frequency
Thanks for the comprehensive answer!
-
- Posts: 6
- Joined: Fri Oct 27, 2023 7:26 pm
Re: API to get CPU frequency
In 5.0+ it seems that esp_clk has been rendered something which is not stable/not something that should be relied upon.
Is there any other way to get the clock speed now that this is no longer a recommended possibility (requires using esp_private api elements)?
I was hoping to use this to do bit banging at fast frequencies.
Is there any other way to get the clock speed now that this is no longer a recommended possibility (requires using esp_private api elements)?
I was hoping to use this to do bit banging at fast frequencies.
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Who is online
Users browsing this forum: No registered users and 119 guests