cancel
Showing results for 
Search instead for 
Did you mean: 

stm32F100 I2C1 and SPI3

jongin bang
Associate
Posted on March 31, 2017 at 03:42

mcu: stm32f100vct

I am using spi3 and i2c1 together.

However, when i2c1 is used, no signal is output from mosi of spi3.

If i2c1 is deleted, spi3 will operate normally.

If i2c1 and spi1 (remap) are used, I2c SMBA does not work, but spi3 does not work?

If available, please let us know the source.

Thank you.

void SPI3_Init(void)

{

    hspi3.Instance = SPI3;

    hspi3.Init.Mode = SPI_MODE_MASTER;

    hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;   

    hspi3.Init.NSS = SPI_NSS_SOFT;

    hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;

    hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;

    hspi3.Init.Direction = SPI_DIRECTION_2LINES;

    hspi3.Init.DataSize = SPI_DATASIZE_8BIT;

    hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;

    hspi3.Init.TIMode = SPI_TIMODE_DISABLE;

    hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;   

  //  hspi3.Init.CRCPolynomial = 7;

    HAL_SPI_DeInit(&hspi3);   

    if (HAL_SPI_Init(&hspi3) != HAL_OK)

    {

        Error_Handler();

    }

}

void I2C1_Init(void)

{   

    hi2c1.Instance = I2C1;

    hi2c1.Init.ClockSpeed = 400000;

    hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;

    hi2c1.Init.OwnAddress1 = 0;

    hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;

    hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;

    hi2c1.Init.OwnAddress2 = 0;

    hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;

    hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;

   

    HAL_I2C_DeInit(&hi2c1);

    HAL_Delay(5);   

    if (HAL_I2C_Init(&hi2c1) != HAL_OK)

    {

        Error_Handler();

    }

    HAL_Delay(5);

}
0 REPLIES 0