Skip to content
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

STM32F1 UART TX idles after every byte #1309

Closed
jlpoltrack opened this issue Feb 25, 2021 · 2 comments · Fixed by #1313
Closed

STM32F1 UART TX idles after every byte #1309

jlpoltrack opened this issue Feb 25, 2021 · 2 comments · Fixed by #1313

Comments

@jlpoltrack
Copy link

jlpoltrack commented Feb 25, 2021

Describe the bug
When using UART1 on STM32F1, TX seem to idle after every byte sent. Don't expect this idle period.

To Reproduce
Source from Arduino IDE:

void setup() {
  Serial.begin(1000000);
}

void loop() {
  Serial1.printf("Test");
  Serial1.flush();
  delay(100);
}

Screenshot from Scope:

Capture_2021_02_24_18_50_39

Expected behavior
Expect to see continuous output from TX, such as:

Capture_2021_02_24_19_02_24

Screenshots
Screenshots above

Desktop (please complete the following information):

  • OS: Win 10
  • Arduino IDE version: 1.8.13
  • STM32 core version: 1.9.0
  • Tools menu settings if not the default: Default
  • Upload method: Serial

Board (please complete the following information):

  • Name: STM32F103C Blue Pill
@fpistm fpistm added this to To do in STM32 core based on ST HAL via automation Feb 25, 2021
@fpistm fpistm moved this from To do to In progress in STM32 core based on ST HAL Mar 2, 2021
ABOSTM added a commit to ABOSTM/Arduino_Core_STM32 that referenced this issue Mar 3, 2021
Instead of calling HAL for each and every bytes,
try to call it only once for a string.
Several call may be needed to manage internal circular buffer
Fixes stm32duino#1309

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
@ABOSTM
Copy link
Contributor

ABOSTM commented Mar 3, 2021

Hi @jlpoltrack,
As I understand, there is no real issue, you just don't get the full performances.
I don't consider this behavior has a bug, it works the way it has been implemented:
Current implementation send each bytes one by one, even if a multi character string is provided as argument.
And the consequence is that there is interrupt and CPU activity between each bytes (to prepare and send the next bytes).

Nevertheless, I agree that it is not really optimized.
This is why I propose a slightly different implementation in PR #1313

@jlpoltrack
Copy link
Author

@ABOSTM
Thanks for the response and explaining the current implementation. As I didn't see this mentioned in the API documentation, thought I had something wrong with my setup. I noticed when I saw a regression in packet size at higher UART speeds.
I look forward to trying out the new implementation in the future.

ABOSTM added a commit to ABOSTM/Arduino_Core_STM32 that referenced this issue Mar 10, 2021
Instead of calling HAL for each and every bytes,
try to call it only once for a string.
Several call may be needed to manage internal circular buffer
Fixes stm32duino#1309

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
STM32 core based on ST HAL automation moved this from In progress to Done Mar 10, 2021
fpistm pushed a commit that referenced this issue Mar 10, 2021
Instead of calling HAL for each and every bytes,
try to call it only once for a string.
Several call may be needed to manage internal circular buffer
Fixes #1309

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

3 participants