embassy-rs / embassy

Modern embedded framework, using Rust and async.
https://embassy.dev
Apache License 2.0
5.44k stars 752 forks source link

Issue sending data correctly over USART in debug mode #571

Open olofwalker opened 2 years ago

olofwalker commented 2 years ago

I'm seeing a weird problem when I try to interface two STM32 Nucleo boards using a UART.

When running in debug mode I see sporadic errors, sometimes I see the server receiving the string with a leading zero. Sometimes the client receives nothing.

I have been using the trace debug level to check what data that goes in and out, and the receiving side seems to get a bit of garbage, the data looks fine when sending it.

When running in release mode, or in blocking mode, I have not seen these errors.

It feels like some timing error or some baud rate error.

Server:

embassy-server

Client: embassy-client

olofwalker commented 2 years ago

One thing that was discovered after posting this. On the server-side, the buffer used for RX and TX was the same, when using a separate buffer it seems to work reliably in debug mode also.

Dirbaio commented 2 years ago

Either way, you'll probably want to add some kind of framing to the packets to be resilient to bit errors, especially if you're not using RTS/CTS.

olofwalker commented 2 years ago

@Dirbaio I will have a look at how to configure the RCC to clock from HSE.

I have unfortunately no access to a logic analyzer at this point.