-
Notifications
You must be signed in to change notification settings - Fork 7.6k
setCpuFrequencyMhz() changes Serial bauds if frequency<80Mhz #6032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks @Leonleon33 for reporting and solving the issue with your example. |
I encounter the same problem. these are the firmware versions I'm using:
through PlatformIO with with ESP32-S3 |
This PR is already merged and it is part of Arduino Core 2.0.2+ |
But why do i then need to ajust the baudrate in the way that was proposed by the issue creator? What I'm doing is going into a different mode that is something like a standby mode. when setting a CpuFrq below 80Mhz i have to update the baudrate accordingly. It also seems like I2C and SPI clocks are also slowed down. SD Card writes also stop working after the reduction of the CPU clock |
If necessary, please open a new issue clarifying the Arduino Core Version, if this issue occurs with Arduino IDE, what is the SoC (ESP32 or the S2/S3/C3) and so on. Describe your issue and then add a minimum sketch that can be used to reproduce the issue. |
I have already supplied all these information. The original sketch provided by the Issue opened still works with the latest Arduino 2.0.4 and ESP32-S3 Devkit C-1. But ill open a new issue |
try this when change cpu frequency
|
That's quite a neat hack !!
|
The above solution does not work for me. I get a crash on an ESP32 S3 8MB when I change to clock speed to 10MHz.
here's my code:
the original code can be found here: |
Arduino Core 2.0.7+ sets the clock source of UART to UART_SCLK_XTAL in the ESP32-S3. arduino-esp32/cores/esp32/esp32-hal-uart.c Lines 202 to 210 in 8873adb
This change in the code was introduced at the end of 2022 by this commit 99f66d3 in the PR #7496 |
So i read. |
I just tried a sketch changing the clock speed from 240,160,80,40,26,24,20,13,12,10,5,4,2,1. |
Haven't tested at 2 baud ....or 1 . |
I had a typo. It was 2 x baud. IE, at 40 MHz, I had to set the serial port to 230400 to get 115200 output. All other settings I was able to use 115200 to get 115200. |
I can confirm, serial baud is correct at 240, 160, 80, 20, and 10 MHz, but incorrect at 40 MHz. Serial.begin must be called after changing frequency to 10 MHz (and probably when changing to 20 as well). |
here's a draft of my code with @JasonPittenger's solution:
the original code can be found here: |
This will set the serial speed to 2 x for all speeds below 80, which isn't correct. I think what you want is
|
Here's my code snippet updated with @JasonPittenger solution
the original code can be found here: |
Board
ESP32 Dev module
Device Description
ESP32 Dev module alone
Hardware Configuration
Nothing
Version
v2.0.1
IDE Name
Arduino IDE
Operating System
Ubuntu 20.04
Flash frequency
80Mhz
PSRAM enabled
no
Upload speed
921600
Description
When setting CPU frequency below 80Mhz, the serial monitor is garbage until I change the baud rate...
I manage to solve the problem by setting the Serial.begin(bauds) to : 80 / cpufreq * monitor_bauds
See sketch attached.
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: