Skip to main content
Christian Fehrenbacher
Associate
December 12, 2016
Question

stm32f4 to stm32f7 port Spi wrong clk signal

  • December 12, 2016
  • 1 reply
  • 1163 views
Posted on December 12, 2016 at 14:28

Hello,

until now I have a custom board with a stm32f4 and it works fine with the standard peripheral lib.

I tried the new stm32f767 and the board started working after a few changes.

Except the SPI, I can receive and transmit data, the CS works, but the clock signal is wrong.

I need a data length of 8 bit, but I get 16 Bit.

(I get 16 pulses at the clock pin instead of 8, the signal on MOSI, MISO and CS are correct)

I don't see my mistake in the register settings, what did I miss?

spi2->CR1     : 0x035D

spi2->CR2     : 0x1700

spi2->SR      : 0x0643

spi2->DR      : 0x040C

spi2->CRCPR    : 0x0007

spi2->RXCRCR  : 0x0000

spi2->TXCRCR  : 0x0000

spi2->I2SCFGR : 0x0000

spi2->I2SPR      : 0x0002

I don't use HAL because it would be a lot of work to port the whole project and the register differences are small.

Thanks for every suggestion.

Kind regards

Chris

#clk #spi #stm32f4 #clock #stm32f7 #stm32f767
This topic has been closed for replies.

1 reply

waclawek.jan
Super User
December 12, 2016
Posted on December 12, 2016 at 15:00

F7's SPI features the unfortunate data packing feature, contrary to F4. Do you take this into account when writing into SPIx_DR?

JW

Christian Fehrenbacher
Associate
December 12, 2016
Posted on December 12, 2016 at 15:39

Hello JW,

tanks for the respond.

The data pins (MOSI and MISO) are fine, the data arrives, only the clk signal is wrong.

In the CR2 Register is the DS part, where you can configure the data length.

I need 8 Bit, but if I set it to  8-Bit I get 16.

If I set it to 5 Bit I get 10 and so on.

I tried to set it to 0, that's a forbidden value, it should force the data length to 8 according to the manual, but ended in 16 Bit.

I read the register value back right before the read operation and after the initialisation, there is no corruption after the initialisation.

If I set the data length to 4 Bit, it generates the 8 Bit I want, so I am happy with that work around.

Perhaps it is a error in the manual ...

greetings

Chris

waclawek.jan
Super User
December 12, 2016
Posted on December 12, 2016 at 15:42

Chris,

read the 'data packing' subchapter in the 'F7 RM.

Jan