Question
SPI problem in STM32F10x
I have a problem with setting up SPI1 in Master mode using the following code. I set the SSM bit to enable software slave management, but when I try to enable the SPI by setting the SPE bit, the MSTR bit is cleared.
Thanks for help.
Jaroslav
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN | RCC_APB2ENR_AFIOEN | RCC_APB2ENR_SPI1EN;
GPIOA -> CRL &= 0x000FFFFF;
GPIOA -> CRL |= 0xB4B00000; /// PA7 - MOSI, PA6 - MISO, PA5 - SCK
SPI1->CR1 &= ~SPI_CR1_BR; // baud rate = fpCLK/2
SPI1->CR1 &= ~SPI_CR1_CPOL;
SPI1->CR1 |= SPI_CR1_CPHA;
SPI1->CR1 &= ~SPI_CR1_DFF;
SPI1->CR1 &= ~SPI_CR1_LSBFIRST;
SPI1->CR1 |= SPI_CR1_SSM; // software slave management
SPI1->CR1 |= SPI_CR1_MSTR;
SPI1->CR1 |= SPI_CR1_SPE;