stm32f4xx-hal icon indicating copy to clipboard operation
stm32f4xx-hal copied to clipboard

SPI sends data discontinuously

Open jensboe opened this issue 4 years ago • 1 comments

Hello, I normally write embedded code in C but I want to learn something new, so I decide to learn RUST. So it's totally possible that I make a mistake.

I setup a SPI and i want that it sends data with 3MHz, it does, but after each byte stops sending & clocking.

What did i wrong or is it an issue in the SPI-HAL? And where can I ask questions instead of opening issues?

    let cp = Peripherals::take().unwrap();
    let dp = stm32::Peripherals::take().unwrap();

    let rcc = dp.RCC.constrain();
    let clocks = rcc.cfgr.sysclk(180.mhz()).pclk1(24.mhz()).freeze();

    let gpioa = dp.GPIOA.split();
    let pins = (
        gpioa.pa5.into_alternate_af5(), // SCK
        gpioa.pa6.into_alternate_af5(), // MISO
        gpioa.pa7.into_alternate_af5(), // MOSI
    );

    let spi_mode = SpiMode {
        polarity: Polarity::IdleLow,
        phase: Phase::CaptureOnFirstTransition
    };
    let mut spi = Spi::spi1(
        dp.SPI1,
        pins,
        spi_mode,
        hal::time::MegaHertz(3).into(),
        clocks,
    );
    loop {
        let data = [0x1u8, 0x3u8, 0x7u8, 0xFu8, 0x1Fu8, 0x3Fu8, 0x7Fu8, 0xFFu8];
        spi.write(&data).unwrap();
        delay.delay_ms(100u32);
    }

jensboe avatar Jan 16 '21 22:01 jensboe

Have you tried compiling it with --release I had an issue recently where I saw the spi stop sending data and I believe it was because the data wasn't getting to the peripheral in time.

peauters avatar Jun 07 '21 16:06 peauters