Skip to main content
lorenzo meneghello
Associate III
Jan 30, 2017 11:53 AM UTC
Solved

SPI1 setting up problem on STM32F09x

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.
    waclawek.jan
    waclawek.janBest answer
    Super User
    Jan 30, 2017 12:47 PM UTC
    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
    Jan 30, 2017 12:47 PM UTC
    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
    Jan 30, 2017 3:30 PM UTC
    Posted on January 30, 2017 at 15:30

    Thanks that was the problem!