Electronic – Understanding SPI

spistm32

I have some problems understanding SPI:

I am currently using STMF2xx to connect with FTDI UM232H, I will configure my STMF2xx into slave and FTDI into master.

But, I am having problem getting the data in my STM32 from the FTDI, but when I check my signal, I could see my MOSI (FTDI to STM32) signal is correct!

May I know what could be wrong?

But, isn't that my MISO line should be getting the same data as MOSI but is bit shifted?
(am I right? isn't that SPI works like a shift register, whenever sends data into MOSI, the hardware will automatically output to MISO?)

My second question is, does it matter if my MOSI line is always LOW, but MISO line is always HIGH? Or do I need to setup that MOSI and MISO must be low/high initial, or MOSI high, MISO low?

My current configuration for my SPI is:

  1. 2 line duplex
  2. 1 Mhz clock
  3. MSB
  4. 8bit
  5. Phase = Low
  6. Polarity = Positive
  7. Hardware: 4 lines connection, CS, SCLK, MOSI, MISO

SPI signal

Best Answer

But, isn't that my MISO line should be getting the same data as MOSI but is bit shifted? (am I right? isn't that SPI works like a shift register, whenever sends data into MOSI, the hardware will automatically output to MISO?)

No. The slave should clock out whatever it has put into the output register. If there is a 0 there, then 0 is clocked out.

My second question is, does it matter if my MOSI line is always LOW, but MISO line is always HIGH? Or do I need to setup that MOSI and MISO must be low/high initial, or MOSI high, MISO low?

Irrelevant. The level only matters when sampled at the appropriate phase and polarity of the clock.

Make sure that the SPI peripheral is enabled in slave mode and that MISO is configured as an output.