2016-12-12 05:28 AM
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 : 0x1700spi2->SR : 0x0643spi2->DR : 0x040Cspi2->CRCPR : 0x0007spi2->RXCRCR : 0x0000spi2->TXCRCR : 0x0000spi2->I2SCFGR : 0x0000spi2->I2SPR : 0x0002I 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 #stm32f7672016-12-12 06:00 AM
F7's SPI features the unfortunate data packing feature, contrary to F4. Do you take this into account when writing into SPIx_DR?
JW
2016-12-12 07:39 AM
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
2016-12-12 07:42 AM
Chris,
read the 'data packing' subchapter in the 'F7 RM.
Jan
2016-12-13 12:33 AM
Hello Christian,
Jan is right. On the F303, there is the same feature and if you just write SPIx.DR = data, the compiler will assume that you want to write 16 bits to DR (because DR is 16 bits, even if data is an 8 bits variable). The trick here is to force an 8-bit write to DR, like this:
*(__IO uint8_t *) ((uint32_t)SPIx + (uint32_t)0x0C) = data; // Replace SPIx with the actual SPI you are using
Have a nice day,
Carl
P.S. How do you format code in the new forum software ?
2016-12-13 12:39 AM
Hello Jan and Carl,
thanks for the help.