This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Getting SPI to work

Hi, I'm using a MCBSTM32E board, with a ST32E103ZE Arm Cortex M3 processor. I am trying to get the SPI interface to work, but so far I've had no luck.

I've tried simulating, and capturing the pin outputs with an oscilloscope, but I get no output.

Relevant code:

void M_SPIInit(void)
{
        SPI_InitTypeDef SPI_InitStructure;

        // SPI1 configuration
        SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
        SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
        SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b;
        SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
        SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
        SPI_InitStructure.SPI_NSS = SPI_NSS_Hard;
        SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
        SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
        SPI_InitStructure.SPI_CRCPolynomial = 7;
        SPI_Init(SPI1, &SPI_InitStructure);
}

int main (void)
{
        stm32_Init();
        M_SPIInit();
        SPI_Cmd(SPI1, ENABLE);
        SPI_I2S_SendData(SPI1,word);
}

Parents
  • I have tried setting NSS to Software, but no change.

    I have configured the GPIOs like this:

    NSS - Floating input
    SCK - Alternate Function Push-pull (Max 50 MHz)
    MISO - Floating input
    MOSI - Alternate Function Push-pull (Max 50 MHz)

    I have no idea which clocks to set, I'm using their configuration wizard. They are set (as far as I can tell) like this:

    External Clock Enabled (8 MHz)
    PLL Enabled, 8 times multiplier and does not exceed maximum of 72 MHz.
    PLL source : HSE clock
    PLLXTPRE : HSE
    System Clock switch : PLL clock

Reply
  • I have tried setting NSS to Software, but no change.

    I have configured the GPIOs like this:

    NSS - Floating input
    SCK - Alternate Function Push-pull (Max 50 MHz)
    MISO - Floating input
    MOSI - Alternate Function Push-pull (Max 50 MHz)

    I have no idea which clocks to set, I'm using their configuration wizard. They are set (as far as I can tell) like this:

    External Clock Enabled (8 MHz)
    PLL Enabled, 8 times multiplier and does not exceed maximum of 72 MHz.
    PLL source : HSE clock
    PLLXTPRE : HSE
    System Clock switch : PLL clock

Children