Skip to main content
lorenzo meneghello
Associate III
January 30, 2017
Solved

SPI1 setting up problem on STM32F09x

  • January 30, 2017
  • 2 replies
  • 662 views
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.

    This topic has been closed for replies.
    Best answer by waclawek.jan
    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

    2 replies

    waclawek.jan
    waclawek.janBest answer
    Super User
    January 30, 2017
    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

    lorenzo meneghello
    Associate III
    January 30, 2017
    Posted on January 30, 2017 at 15:30

    Thanks that was the problem!