-
Notifications
You must be signed in to change notification settings - Fork 1k
NUCLEO-H743ZI2 SPI.transfer() fails with SCLK less than 500 kHz in 1.9.0 #1294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I looked at all the SPI signals with a logic analyzer and got a message about incorrect clock polarity. I suspect that the SPI peripheral can not be disabled at the end of transfer() since this will cause a polarity problem for some SPI modes and glitches in the signals. Seems like the peripheral must be enabled from beginTransaction() to endTransaction(). See line 306 of STM32/hardware/stm32/1.9.0/libraries/SPI/src/utility/spi_com.c
|
Hi @greiman, |
Hi @mzhboy, Concerning STM32F4, I tested on NUCLEO_F429ZI (the only F4 board I have), and I could not reproduce the original issue (Clock and Data truncated). And on your screenshot, I don't see such such behavior. |
I don't have H7 board that fix for H7 is just based on reference manual. my issue was happening only when SPI setting was check out if (!skipReceive) {
#if defined(STM32H7xx) || defined(STM32MP1xx)
while (!LL_SPI_IsActiveFlag_RXP(_SPI));
#else
while (!LL_SPI_IsActiveFlag_RXNE(_SPI));
#endif
*rx_buffer++ = LL_SPI_ReceiveData8(_SPI);
}
if ((Timeout != HAL_MAX_DELAY) && (HAL_GetTick() - tickstart >= Timeout)) {
ret = SPI_TIMEOUT;
break;
}
}
|
Hi, I've made some update on the SPI driver. It should be fine to test them --> #1488 |
I downloaded Arduino_Core_STM32-master.zip which has #1488 and replaced my 2.0.0 here: C:\Users\Bill\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0 I tested with my SdFat library using a NUCLEO-H743ZI2. #1488 appeared to help since SdFat works with some SD cards but failed with many. I used the following program to test the new SPI library with the conditions where the SD card fails during initialization.
Here is a capture of the SPI bus using a Saleae Logic Analyzer. The channels are D0 - SS, D1 - MOSI, D2 - MISO, D3 - SCK. Here is the same program on a NUCLEO-F446RE, It does not have the glitches that are present with the NUCLEO-H743ZI2. There is not dead time between bytes. |
Ok. Thanks for the test. We always waiting feedback from internal experts. |
…nals Add a delay before disabling SPI otherwise last-bit/last-clock may be truncated. See stm32duino#1294 Computed delay is half SPI clock. Signed-off-by: Alexandre Bourdiol <[email protected]>
Our experts confirm this issue:
Description Conditions
Implications Workaround |
Workaround has been implemented for STM32H7 and STM32MP1: |
…nals Add a delay before disabling SPI otherwise last-bit/last-clock may be truncated. See stm32duino#1294 Computed delay is half SPI clock. Signed-off-by: Alexandre Bourdiol <[email protected]>
…nals Add a delay before disabling SPI otherwise last-bit/last-clock may be truncated. See #1294 Computed delay is half SPI clock. Signed-off-by: Alexandre Bourdiol <[email protected]>
This sketch illustrates a failure of SPI.transfer with a NUCLEO-H743ZI2. The sketch use a SCLK rate of 400kHz.
The problem is shown in this trace of SCLK in yellow and MOSI in green. The eighth clock pulse and data are chopped.
I looked at the SPI library code and found where the problem occurs, SPI is disabled before the last bit is complete.
The file is: STM32/hardware/stm32/1.9.0/libraries/SPI/src/utility/spi_com.c
If you add a delay here at about line 443:
The SPI frame is correct.
I tried to find a SPI status check to replace the delay but was not successful when I looked at the STM32H743/753 Reference Manual.
The text was updated successfully, but these errors were encountered: