Hello community! I’m diving into the world of STM32 programming and have been focusing on setting up SPI for my STM32H743ZI debug board. While I’ve managed to get things working using HAL libraries, I’m really eager to understand the low-level CMSIS configuration.
I’ve spent the past two weeks digging through forums and documentation, but I’m still stuck. No matter how I configure SPI—whether it’s SPI1, SPI2, or others—the MOSI and SCK pins remain inactive, as confirmed by my oscilloscope. I’m using the following code snippet for initialization, but I suspect I’m missing something crucial in the setup.
c
void SPIinit (void){
/* RCC Configuration */
RCC->AHB4ENR |= RCC_AHB4ENR_GPIOCEN;
RCC->AHB4ENR |= RCC_AHB4ENR_GPIOBEN;
RCC->APB1LENR |= RCC_APB1LENR_SPI3EN;
/* GPIO Configuration */
GPIOC->MODER &= ~GPIO_MODER_MODE12;
GPIOC->MODER &= ~GPIO_MODER_MODE11;
GPIOC->MODER &= ~GPIO_MODER_MODE10;
GPIOC->MODER |= GPIO_MODER_MODE12_1 | GPIO_MODER_MODE11_0 | GPIO_MODER_MODE10_1;
/* SPI Configuration */
SPI3->CFG1 |= SPI_CFG1_MBR_1;
SPI3->CFG2 |= SPI_CFG2_MASTER | SPI_CFG2_CPOL;
SPI3->CR1 |= SPI_CR1_SPE;
/* NVIC Configuration */
NVIC_EnableIRQ(SPI3_IRQn);
}
I’m particularly confused about the correct pin configuration and the initialization sequence. Could it be an issue with the GPIO alternate functions or the SPI clock configuration? Any insights or suggestions would be incredibly helpful! I really appreciate your time and expertise. ![]()