SPI Configuration (bare metal-stm32h743)
I am trying to code the stm32h743 for spi communication and i can't seem to transmit. I am using PA5 as SCK and PD7 as MOSI. I read the procedure required that is in the reference manual (49.4.9 https://www.st.com/resource/en/reference_manual/dm00314099.pdf ) and wrote the code below but it doesn't transmit 0x3 (checked with oscilloscope).
RCC->AHB4ENR |= RCC_AHB4ENR_GPIOAEN; // clock enable for gpio A,B,D
RCC->AHB4ENR |= RCC_AHB4ENR_GPIODEN;
RCC->AHB4ENR |= RCC_AHB4ENR_GPIOBEN;
RCC->APB2ENR |= RCC_APB2ENR_SPI1EN; // enable SPI clock
GPIOA->MODER &= ~GPIO_MODER_MODER5; // enable alternate functions for gpioa and d
GPIOA->MODER |= GPIO_MODER_MODER5_1; // 0b10 for alternate function, (PIN5)
GPIOA->AFR[0] |= (0x05 << 5 * 4); // AF5 for SPI which is 0101 (it's a 4bit variation)
GPIOA->MODER &= ~GPIO_MODER_MODER6; // PIN6
GPIOA->MODER |= GPIO_MODER_MODER6_1;
GPIOA->AFR[0] |= (0x05 << 6 * 4);
GPIOD->MODER &= ~GPIO_MODER_MODER7; // PIN7
GPIOD->MODER |= GPIO_MODER_MODER7_1;
GPIOD->AFR[0] |= (0x05 << 7 * 4);
SPI1->CFG1=(7u << SPI_CFG1_DSIZE_Pos); // 8bit data size
SPI1->CFG2|=SPI_CFG2_MASTER ; // master mode
SPI1->CR1|=SPI_CR1_SPE; // spi enable
SPI1->CR1|=SPI_CR1_CSTART; // transfer start
*(volatile uint8_t *)&SPI1->TXDR = 0x3;I checked with the debugger and all the settings are configured correctly to all the registers up until the last two lines where i don't see any change and can't transmit anything. Master mode (line 19) also doesn't configure, register stays 0. And transfer start bit can't change to 1 if master mode is not enabled.
Any ideas? Also, am i missing any other settings for SPI configuration?
thanks
