SPI on STM32U575 (NUCLEO board)
I'm trying to get SPI1 working on an STM32U575 (NUCLEO board), starting from a base of existing working STM32F4 LL API code, but have failed.
I am running this on a NUCLEO-U575ZI-Q board, so MOSI on PA7 (D11), MISO on PA6 (D12), SCLK on PA5(D13) and with SB63 not bridged so that I can use PB0 (the "IO1" pin of the QSPI pins on CN10) as NSS.
Probing the pins, the SPI1 SCLK does not activate when I attempt to transmit data and the NSS pin stays high (it goes high when I configure SPI1 so it is working, after a fashion). Not sure whether it is relevant but writes to CR1 do not modify the CR1 register contents as seen by the debugger, almost like SPI1 is not enabled (writes to other registers are visible in the debugger). Here are my steps:
// Set source clock and enable SPI clock (all APB clocks have already been configured)
__HAL_RCC_SPI1_CONFIG(RCC_SPI1CLKSOURCE_PCLK2);
__HAL_RCC_SPI1_CLK_ENABLE();
// Disable SPI while we configure
LL_SPI_Disable(SPI1);
// Configure MOSI, MISO, CLK and NSS pins
LL_GPIO_InitTypeDef gpioInitStruct;
gpioInitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
gpioInitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
gpioInitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
gpioInitStruct.Pull = LL_GPIO_PULL_UP;
gpioInitStruct.Alternate = LL_GPIO_AF_5;
gpioInitStruct.Pin = 0x00E0;
LL_GPIO_Init(GPIOA, &gpioInitStruct);
gpioInitStruct.Pin = 0x0001;
LL_GPIO_Init(GPIOB, &gpioInitStruct);
// Configure SPI registers
LL_SPI_SetMode(SPI1, LL_SPI_MODE_MASTER);
LL_SPI_SetBaudRatePrescaler(SPI1, LL_SPI_BAUDRATEPRESCALER_DIV256);
LL_SPI_SetDataWidth(SPI1, LL_SPI_DATAWIDTH_8BIT);
LL_SPI_SetNSSMode(SPI1, LL_SPI_NSS_HARD_OUTPUT);
LL_SPI_SetTransferSize(SPI1, 1);
// Enable SPI
LL_SPI_Enable(SPI1);
LL_SPI_StartMasterTransfer(SPI1);
// Try to transmit the character 'A', but nothing happens on the MOSI/NSS/CLK pins
LL_SPI_TransmitData8(SPI1, 'A');
What have I missed?
