cancel
Showing results for 
Search instead for 
Did you mean: 

I2C and SPI at the same time?

Mmats.503
Associate

Hi. I'm not a English speaker. Sorry for my poor English.

My code including EITHER I2C or SPI works successfully on STM32F303K8T6 Nucleo Board. However, with my code including BOTH I2C and SPI , Only SPI functions work correctly ,but I2Cs don't.

Using a ocsiloscope, It was found that voltage levels of I2C pins don't fluctuate at all when SPI initialization code exists. Is it impossible to use I2C and SPI function at the same time?

#include "main.h"
#include "dac.h"
#include "dma.h"
#include "i2c.h"
#include "spi.h"
#include "tim.h"
#include "usart.h"
#include "gpio.h"
 
int main(void){
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_I2C1_Init();
  MX_USART2_UART_Init();
  MX_DAC1_Init();
  MX_DAC2_Init();
  MX_TIM6_Init();
  MX_SPI1_Init();
  MX_I2C1_Init();
 
  uint8_t aTxBuffer = 0x3F;  //some command to send
  HAL_I2C_Master_Transmit(&hi2c1, DEVICE_ADDRESS, (uint8_t*)aTxBuffer, 1, 1000);
}

The Initialization code was generated by CubeIED Device Configuration Tool.

10 REPLIES 10
BarryWhit
Lead II

Four different people complaining about a similar issue, this looks like more than a random newbie misconfig. At the very least something needs to be communicated better in the docs or through the CubeMX GUI.

 

@STOne-32 , perhaps you have some insight to offer for this thread?

 

 

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.