cancel
Showing results for 
Search instead for 
Did you mean: 

How to drive SPI MOSI to a certain logical level at all time including SPI bus not active

Yang Yang
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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:

Ozone_0-1744616880184.png

https://en.wikipedia.org/wiki/Serial_Peripheral_Interface

 

View solution in original post

7 REPLIES 7
Ozone
Lead III

> 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.

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

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:

Ozone_0-1744616880184.png

https://en.wikipedia.org/wiki/Serial_Peripheral_Interface

 

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

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.

CTapp.1
Senior

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.

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