AnsweredAssumed Answered

F030 SPi initialisation

Question asked by barber.mark on Feb 22, 2017
Latest reply on Feb 22, 2017 by T J

Hi, I am having trouble setting up the SPI port on a F030. The basic initialization code

The Ports are setup for AF0 on ports B3,4,5

    // set baud rate

    SPI1->CR1|=SPI_CR1_BR_0|SPI_CR1_BR_1|SPI_CR1_BR_2;      // set baud rate

    // setup CPOL and CPHA if not correct

    // set for master

    SPI1->CR1|=SPI_CR1_MSTR;                             // set to master

   // set data size

    SPI1->CR2|=SPI_CR2_DS_0|SPI_CR2_DS_1|SPI_CR2_DS_2;  // set for 8 bits

    // configure FRXTH to 8

    SPI1->CR2|=SPI_CR2_FRXTH;

    // now enable peripheral

    SPI1->CR1|=SPI_CR1_SPE;

If I debug and watch what is happening, the bits get set correctly then when I enable the peripheral the enable bit does not get set and the master bit is cleared. I suspect I am not doing it in the right sequence but cannot find any comments on the right sequence.

Any help appreciated.

Outcomes