cancel
Showing results for 
Search instead for 
Did you mean: 

SPI1 setting up problem on STM32F09x

lorenzo meneghello
Associate II
Posted on January 30, 2017 at 12:53

Hi all,

I'm trying to setting up the SPI interface on my STM32F091, I would use the SPI1 on the PB3&PB5 pin.

This is my simple code:

RCC->APB2ENR |= (1<<12); 

GPIOB->MODER |= 0x880;

GPIOB->OSPEEDR |= 0xCC0;

SPI1->CR1 = SPI_CR1_MSTR | SPI_CR1_BR_1 | SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE; 

SPI1->CR2 = SPI_CR2_FRXTH | SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0; 

SPI1->CR1 |= SPI_CR1_SPE;

On debug I see that when I set the SPI_CR1_SPE bit, the SPI_CR1_MSTR bit is cleared and also the SPI_CR1_SPE bit not comes on.. Why? Something wrong? I want to send data only not receive.

Thanks.

Lorenzo.

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on January 30, 2017 at 13:47

NSS (when unconnected to external pin) is at zero which switches SPI to slave.

Use software SS.

JW

View solution in original post

2 REPLIES 2
Posted on January 30, 2017 at 13:47

NSS (when unconnected to external pin) is at zero which switches SPI to slave.

Use software SS.

JW

Posted on January 30, 2017 at 15:30

Thanks that was the problem!