Question
SPI data transfer is not working when using registers to initialize the SPI unit
I used this function to initialize and setup STM32H743IIT6 uC to work with SPI in master mode:
void InitSPI(void)
{
RCC->APB2ENR=0x00102000; //Enabling SPI45 clock (default: rcc_pclk2=25MHz)
SPI4->CFG1=0x30070007; //Baud rate = SPI clock / 16 = 1.5625 MHz, No CRC, 8 data bits
SPI4->CFG2=0x00C00000; //CPOL=0, CPHA=0, LSB first, Master SPI, Full-duplex
SPI4->CR2=0x00000000; //Size of transfer is unknown and should be 0 (EOT will never happen)
SPI4->IFCR=0x00000200; //Clear possible mode faults
SPI4->CR1=0x00000001; //Enabling SPI
SPI4->CR1=0x00000201; //Enabling data transmission
}after initialization, I use this function to transceive data:
unsigned int TransceiveSPI(unsigned int TransmitSPIData)
{
while((SPI4->SR & SPI_TXD_REGISTER_EMPTY_MASK)==0); //Waiting for last transmission to complete
SPI4->TXDR=TransmitSPIData; //Set the new data to transmit
while (((SPI4->SR & SPI_RECEPTION_COMPLETE_MASK)==0));//Waiting for reception of new data
return SPI4->RXDR; //return the received data
}but no data is transmitted (even if no CLOCK signal is available on the uC pin)! What is the problem?
