Home › Forums › English support forum › rtc_clk_cpu_freq issue
- This topic has 7 replies, 4 voices, and was last updated 11 months, 1 week ago by Radian Voiculescu.
-
AuthorPosts
-
23/10/2023 at 16:59 #1711Ales KrapezParticipant
Hi.
I have an issue with uploading sketch.‘rtc_clk_cpu_freq_set’ was not declared in this scope
Is there any solution?
Thank you31/10/2023 at 21:19 #1713Koray TuncerParticipantYes same problem:
Board ESP-Wroom-32
I try the sketch temparature sensor only.rtc_clk_cpu_freq_set’ was not declared in this scope
Need an urgent solution if possible.
Sincerely,01/11/2023 at 09:51 #1714Ales KrapezParticipantI noticed that the problem is in “slowDownCpu” in Sketch 3.1 this code did not exist and these versions work (at least for me)
[code]
void setup() {
Serial.begin(115200);
slowDownCpu();
pinMode(ONBOARD_LED_PIN, OUTPUT);pinMode(RELAY_PIN, OUTPUT);
dht.setup(DHT_PIN, DHT_TYPE);
setUpWifi();
lastReceivedRelayCommandMilis = millis();
}
void slowDownCpu() {
rtc_clk_cpu_freq_set(RTC_CPU_FREQ_160M);
uart_tx_wait_idle(0);
int clockspeed = rtc_clk_cpu_freq_get();char* clockSpeeds[5] = {“XTAL”, “80Mhz”, “160Mhz”, “240Mhz”, “2Mhz”};
Serial.print(“Setting CPU freq to: “);
Serial.println(clockSpeeds[clockspeed]);
Serial.println(“”);
}[/code]
If you isolate this code in version 3.4, everything works
01/11/2023 at 20:59 #1715Koray TuncerParticipantI think it is not the right solution, but i disabled some codes with //
[code]
void setup() {Serial.begin(115200);
//slowDownCpu();
pinMode(ONBOARD_LED_PIN, OUTPUT);dht.setup(DHT_PIN, DHT_TYPE);
setUpWifi();
}//void slowDownCpu() {
//rtc_clk_cpu_freq_set(RTC_CPU_FREQ_160M);
//uart_tx_wait_idle(0);
//int clockspeed = rtc_clk_cpu_freq_get();//char* clockSpeeds[5] = {“XTAL”, “80Mhz”, “160Mhz”, “240Mhz”, “2Mhz”};
//Serial.print(“Setting CPU freq to: “);
//Serial.println(clockSpeeds[clockspeed]);
//Serial.println(“”);
//}
[/code]It worked.
Does anyone know the right solution?01/11/2023 at 21:33 #1716adminKeymasterHi there!
I would not say, that it is not the right solution. It seems that the board you are using is not exactly the same as the board I used to develop the project, and it behaves differently when it comes to modifying the CPU frequency.
The ‘slowDownCpu’ function is used to slightly slow down the CPU and save energy, as it’s not at all necessary to run at the maximum speed the ESP board can offer. Removing this function will only result in your ESP board consuming a bit more energy, but it will likely be negligible.
Regards!
02/11/2023 at 10:47 #1718Koray TuncerParticipantDear Admin,
Thank You for your reply.
Whats is your ESP32 board model exactly?
Sincerely,05/11/2023 at 10:29 #1721Ales KrapezParticipantNow I pasted another code for CPU speed (and it works). I hope the admin won’t be offended.
[code]
#include “esp32-hal-cpu.h”void setup(void)
{
Serial.begin(115200);setCpuFrequencyMhz(80); //Set CPU clock from 80MHz to 240MHz for example
Serial.println();
Serial.print(“CPU Frequency is: “);
Serial.print(getCpuFrequencyMhz()); //Get CPU clock
Serial.print(” Mhz”);
Serial.println();
}[/code]
Please can you look into why the code in the previous post is not working.
Thank you29/12/2023 at 20:35 #1727Radian VoiculescuParticipantSolved the above problem by installing a older version of ESP32 in Board Manager (v 1.0.4)
-
AuthorPosts
- You must be logged in to reply to this topic.