embassy-rs / embassy

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

stm32/usart: Immediate Error::Overrun when receiving data with embassy_stm32::usart::BufferedUart or RingBufferedUartRx #1441

Open janschiefer opened 1 year ago

janschiefer commented 1 year ago

I'm trying to communicate with a LTE modem and run into a couple of problems with the current UART implementations of embassy_stm32.

Tested on an old STM32F103C8T6 "BluePill" board with original STM32.

abelREK commented 10 months ago

I have also replicated this issue on a STM32f405RG.

mxseev commented 6 months ago

Perhaps the problem is in the default RCC configuration. I had the same issue on my STM32F411CEU6 (Black pill), but after manual RCC setup (at least enabling HSE) everything worked fine. My config (black pill has an external quartz at 25mhz.):

    let mut config = Config::default();
    config.rcc.hse = Some(Hse {
        freq: Hertz(25_000_000),
        mode: HseMode::Oscillator,
    });
    config.rcc.pll_src = PllSource::HSE;
    config.rcc.pll = Some(Pll {
        prediv: PllPreDiv::DIV25,
        mul: PllMul::MUL200,
        divr: Some(PllRDiv::DIV2),
        divp: Some(PllPDiv::DIV2),
        divq: None,
    });
    config.rcc.ahb_pre = AHBPrescaler::DIV1;
    config.rcc.apb1_pre = APBPrescaler::DIV2;
    config.rcc.apb2_pre = APBPrescaler::DIV2;
    config.rcc.sys = Sysclk::PLL1_P;

    let p = embassy_stm32::init(config);
FourLeafTec commented 1 month ago

Same issue on STM32F407VET6.