2020-05-12 05:18 AM
Hello,
I know it sounds like a basic and dumb question but I actually didn't find the answer.
I have communication issues between 2 STM32H743 based Nucleos.
On the master I use SPI1.
If I use SPI1 on the Slave it works fine (repeated send/receive communications).
If I use SPI2 on the Slave, I have communication issues: the Slave receives data correctly but the Master receives crap (CRC error).
The settings are:
So my question: when using alternate function for a GPIO, does the pullup/pulldown setting matter ? Same question for output type (push-pull / open drain) ? And what settings should be used for SPI pins ? HAL examples from ST set all SPI pins with pull-down and push-pull. Is it correct ?
2020-05-12 08:44 AM
The single most important thing is to have short interconnections (that includes paths on the PCB, 10cm may be too long, stubs on the PCB going to some different onboard chip may have impact), good ground/return, best is individual return for each signal and signal wires twisted with their respective return.The most important is to maintain SCK integrity. VeryHigh OSPEEDR may be surprisingly wrong, try lower. You may need to add series terminator resistors to impedance-match.
If you switch off SPI between transactions, make sure slave is deselected the whole time (NSS is high).
OTYPER push-pull; pulldowns mostly don't matter as the lines are supposed to be hard driven from the respective party whenever needed.
JW
2020-05-12 06:51 PM
SPI1 and SPI2 are on different APBs, which typically have different clocks. Your slave SPI clock should be higher than the master clock by 2x. Lower the master clock or increase the slave clock and try it. Could also be the slave doesn't push data out fast enough for the master. A logic analyzer would provide more insight.
2020-05-12 11:44 PM
> A logic analyzer would provide more insight.
+1
2020-05-13 12:42 AM
Thank you, I didn't know for high speed being wrong. Will give it a try. I don't use NSS at all
2020-05-13 12:43 AM
yes sure, slave processing speed is definitely an issue, i am taking it into account. Unfortunately I don't have a logic analyser but agree with our comment.
Why did you strike through the first sentence ? Is it wrong ? (didn't have time to check yet)
2020-05-13 06:04 AM
About your comment the ref manual says:
"There is no specific constraint concerning the frequency ratio between these clock signals (spi_pclk and spi_ker_clk). The user
has to consider a ratio compatible with the data flow speed in order to avoid any data
underrun or overrun events only."
and
"The SPI working in slave mode handles data flow using the serial interface clock derived
from the external SCK signal provided by external master SPI device. That is why the SPI
slave is able to receive and send data even when the spi_pclk and spi_ker_ck clock
signals are inactive."
2020-05-13 06:38 AM
So my question: when using alternate function for a GPIO, does the pullup/pulldown setting matter ? Same question for output type (push-pull / open drain) ? And what settings should be used for SPI pins ? HAL examples from ST set all SPI pins with pull-down and push-pull. Is it correct ?
Find the settings applicability below.
2020-05-13 07:07 AM
Sorry I don't understand the meaning of this figure.
2020-05-13 08:52 AM
> when using alternate function for a GPIO, does the pullup/pulldown setting matter ?
Yes.
> Same question for output type (push-pull / open drain) ?
Yes.
> And what settings should be used for SPI pins ?
Whichever fits your application. With SPI, it would be typically push-pull, no pullup/pulldown; but then there are also non-typical applications.
JW