2025-04-13 8:21 PM
Hello, ST experts
It seems that SPI_MOSI on STM32F407 does not show a certain level. So it is vulnerable by other sources. Is that a register bit like SPI_MASTER_KEEP_IO_STATE_ENABLE on STM32U595? So that MOSI can keep a certain level.
Best Regards
Yang
Solved! Go to Solution.
2025-04-14 12:49 AM
Checking the F40x reference manual, I can't find any reference defining the state when SPI is inactive.
I use to have external pull-up resistorson those pins, and serial resistors for applications like SD cards.
The Wiki page suggests data lines are tristate (floating) when inactive:
https://en.wikipedia.org/wiki/Serial_Peripheral_Interface
2025-04-13 11:43 PM
> It seems that SPI_MOSI on STM32F407 does not show a certain level.
How did you arrive at that conclusion ?
It works fine for me.
I suggest to share the relevant part of the schematics, and the init code for SPI.
2025-04-13 11:54 PM
Hello, Ozone
I mean the MOSI pin is float when SPI bus is not active. I found that by seeing some glitches on spi_mosi when spi_sclk rise or fall(I think that is cross-interference). And some experiments have been done for this case. When SPI is set to 2Linex_RX_Only, there are no glitches on mosi pin when sclk changes.
By the way, SPI peripheral works well in our design except that there are some glitches on spi_mosi pin.
BR
Yang
2025-04-14 12:49 AM
Checking the F40x reference manual, I can't find any reference defining the state when SPI is inactive.
I use to have external pull-up resistorson those pins, and serial resistors for applications like SD cards.
The Wiki page suggests data lines are tristate (floating) when inactive:
https://en.wikipedia.org/wiki/Serial_Peripheral_Interface
2025-04-14 1:06 AM - edited 2025-04-14 1:06 AM
Hello, Ozone
I am appreciated for your help. A pulldown resistor is a good way to prevent float pin. But our hardware can not be easily changed now. So is there any way to set SPI_MOSI pin to a certain state through software setting.
I tried to set SPI_MOSI pin as a GPIO. But it seems still it is controled by SPI peripheral. Actually almost all the time I don't need SPI transmit operation.(STM32F407 works as SPI master)
BR
Yang
2025-04-14 3:33 AM
While I haven't found an explicit statement in the reference manual, it seems the "Z" state (tristate/floating) is standard for this unused pins. If glitches originating from nearby data lines are visible, it means no side is driving this line, and it shouldn't be a problem.
> But our hardware can not be easily changed now.
I heard that quite often from hardware guys. Until they had to change it ...
> I tried to set SPI_MOSI pin as a GPIO. But it seems still it is controled by SPI peripheral.
I would suggest to consult the reference manual + datasheet in this regard.
I don't know if you can mix GPIO settings (like internal pull-up/pull-down) with peripheral settings - in most cases, the selected AF mode overwrites such settings AFAIK.
2025-04-14 7:15 AM
Are you using CubeMX to configure the hardware?
I've got an STM32G4 project, and the SPI configuration in MX allows me to add a pull-up or pull-down to the SCK, MOSI and MISO signals.
2025-04-14 7:29 AM
Hello
Yes I am using CubeMX to generate the code framework. Thanks for your advise, I can add pull-up or pull-down directly in stm32f4xx_hal_msp.c. I will have try too.
BR
Yang