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).
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. Any ideas? Also, am i missing any other settings for SPI configuration?
thanks
Code:
RCC->AHB4ENR |= (1 << 0) | (1 << 1) | (1 << 3); // enable gpio clocks
GPIOA->MODER &= ~(0x3 << 10) & ~(0x3 << 12); // enable alternate functions for gpioa and d
GPIOA->MODER |= (0x2 << 10) | (0x2 << 12);
GPIOD->MODER &= ~(0x3 << 14);
GPIOD->MODER |= (0x2 << 14);
GPIOA->AFR[0] &= ~(0xF << 20) & ~(0xF << 24); // choose alternate function SPI (AF5)
GPIOA->AFR[0] |= (0x5 << 20) | (0x5 << 24);
GPIOD->AFR[0] &= ~(0xF << 28);
GPIOD->AFR[0] |= (0x5 << 28);
RCC->APB2ENR = 0x1000; // enable spi clock
SPI1->CFG2 |= (1 << 22); // master mode
SPI1->CFG1 &= ~(0x1F << 0); // 8bit mode
SPI1->CFG1 |= (0x7 << 0);
SPI1->CR1 |= (1<<9) | (1<<0); // spi enable and master transfer start
*(volatile uint8_t *)&SPI1->TXDR = 0x3; // send 0x3
thanks