2026-03-01 7:01 PM - last edited on 2026-03-09 3:49 AM by KDJEM.1
I am currently using the NUCLEO-H563ZI board to test SPI functionality.
I configured SPI1 as a master and was able to successfully transmit and receive data using HAL_SPI_TransmitReceive(). However, when I switched to SPI2, I found that the clock signal does not toggle at all, no matter what I try.
Is there anything specific that needs to be configured additionally for SPI2?
Below is my code; the rest was automatically generated by MX.
uint8_t spi_TransmitReceive(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin,
const uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout)
{
HAL_StatusTypeDef status;
HAL_GPIO_WritePin(GPIOx, GPIO_Pin, GPIO_PIN_RESET);
status = HAL_SPI_TransmitReceive(&hspi2, pTxData, pRxData, Size, Timeout);
HAL_GPIO_WritePin(GPIOx, GPIO_Pin, GPIO_PIN_SET);
return status;
}
void example_spi_transmitreceive()
{
printf("\r\nExample SPI Transmit and Receive.\r\n");
uint8_t txbuf[1024];
uint8_t rxbuf[1024] = {0};
for(int i = 0; i < 1024; i++) {
txbuf[i] = i & 0xff;
}
spi_TransmitReceive(GPIOB, GPIO_PIN_6, &txbuf, &rxbuf, 1024, 10);
printf("\r\nRx Received data:\r\n");
for(int i = 0; i < 1024; i++) {
printf("0x%02x, ", rxbuf[i]);
if ((i+1) % 16 == 0) {
printf("\r\n");
}
}
}
Solved! Go to Solution.
2026-03-01 7:29 PM
Do functions return HAL_OK? If so, probably the pin you are monitoring is not connected to the clock where you’re measuring. Check the board schematic.
2026-03-01 7:29 PM
Do functions return HAL_OK? If so, probably the pin you are monitoring is not connected to the clock where you’re measuring. Check the board schematic.
2026-03-01 8:02 PM
It does return HAL_OK.
I am using PA12 as the SPI2 clock pin, and I am confident that I connected to the correct pin since the board silkscreen clearly labels it as PA12.
Below are the pins I am using:
PC2 ------> SPI2_MISO
PC3 ------> SPI2_MOSI
PA12 ------> SPI2_SCK
PB6 ------> SS
2026-03-01 8:20 PM
2026-03-01 9:14 PM
Hi TDK,
Thank you very much for your help. I had never considered that an EVB might have DNF pin headers.
I really appreciate your patience in explaining this to a beginner like me. Thanks again!