cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 SPI Issue

harikk09
Associate II
Posted on August 03, 2011 at 08:24

Hai,

I am using STM32F103ZE

I am not getting SPI data correctly.

Master is transmitting correctly.

But always read as zero where a non zero value has been sent.

Master config: (MSP430)

The master configuration is correct. (I tested it.)

Master Mode, MSB First, 8-bit SPI, Inactive state is high., ss grounded, 1 MHz clock, no dividers

Slave Config (STM32F103ZE)

Using SPI2.

  SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Rx;

  SPI_InitStructure.SPI_Mode = SPI_Mode_Slave;

  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;

  SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;

  SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;

  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;

  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;

  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;

  SPI_InitStructure.SPI_CRCPolynomial = 7;

Anybody have an answer,

Thanks

Hari

#stm32 #versaloon #stm32f103ze-spi #spi
11 REPLIES 11
harikk09
Associate II
Posted on August 05, 2011 at 15:42

Thanks for your reply.

In My master I am configuring CPHA = low, and CPOL = high

That was my problem.

The I thought that the CPHA must be same for both master and slave

Thanks a lot for your help clive1.

tablockblog
Associate
Posted on September 27, 2013 at 14:42

Yes, same CPOL and CPHA is very important for SPI interface, it was also some problem for me with using it via versaloon programmer and stm32 spi slave, and

http://tablock.org.ua/post/99/STM32+SPI+Slave+%D0%B8+%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D1%84%D0%B5%D0%B9%D1%81+SPI+%D0%B2+Versaloon+%28USB_TO_SPI%29

are some detail description about SPI modes in versaloon SPI interfaces.