Skip to main content
RShiv.1
Associate III
November 18, 2022
Solved

I2C not working with STM32F103C6 and STM32F103C8

we have been trying to get the I2C up on both the controller and no responses from anyone the cubeMx issue if I2C is really a problem..Kindly respond as we are trying to get I2C up ..

requesting the experience forum experts to respond.

Thanks

Ravi

This topic has been closed for replies.
AScha.3
AScha.3Best answer
Super User
November 25, 2022

from the ds you posted, i cannot say, what to do better.

now lets stop  to play blind cow . :)

so look, what drivers exist and learn/copy from them :

here sensirion gives driver for their sensor:

https://github.com/Sensirion/embedded-i2c-scd30

and many others...(also in c++, rust etc.)

https://github.com/paulvha/scd30

https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library

https://github.com/RequestForCoffee/scd30

https://github.com/adafruit/Adafruit_SCD30

https://github.com/Seeed-Studio/Seeed_SCD30

https://github.com/watterott/CO2-Ampel

https://github.com/sinewave-ee/scd30-rs

the driver by sensirion should show you, what to do.

If you feel a post has answered your question, please click on " Best Answer ".

63 replies

RShiv.1
RShiv.1Author
Associate III
November 21, 2022

Yes I understood that point...but I thought that is implicit from slave...then since I tried that using HAL_calls...I will once again try enabling it and update you ASAP

RShiv.1
RShiv.1Author
Associate III
November 21, 2022

Hi,

I even tried with clock stretch did not work...any thing else needed to be done..atleast in bit bang I saw the I2C_init() went through...but here even I2C clck is not visible in the scope..even device ready is not working...let me know if there are any configurations needed to be done

RShiv.1
RShiv.1Author
Associate III
November 21, 2022

Hi,

any update on this...we tried the python code in raspberry pi ..there since i2c got detected ..we were able to see the values from the sensor...only difference here is i2C is not working even after trying either bit bang or in HAL mode...kindly let me know if anyone can tell me how i2C transmit can be done.

thanks

Ravi

RShiv.1
RShiv.1Author
Associate III
November 21, 2022

HAL_Isdevice_ready with is not passing through

RShiv.1
RShiv.1Author
Associate III
November 21, 2022

any configuarations changes required kindly let me know...also the bitbanging code for I2C is also attached here also I2C_transmit is not working...let me know any workaround in either of the approach so that we shall move ahead...thanks

AScha.3
Super User
November 21, 2022

if still not working - its time, to look at the signal:

take DSO, 1 ch sck , 1 ch sda ; trigger on clk.

then show, what happens on I2C lines.

If you feel a post has answered your question, please click on " Best Answer ".
RShiv.1
RShiv.1Author
Associate III
November 22, 2022

Hi,

As said earlier the result with respect to SDA and SCL lines are as below

  1. with HAL Libraries used , when

why is CLK not seen here???

if (HAL_OK == HAL_I2C_IsDeviceReady(&hi2c1, DevAddress, 200, 2000)) {

printf("I2C success \n");

}

else{

printf("I2C failure \n");

}

No CLK seen in the line (SCL ) so SDA is also flat line

2.With Bitbang approach we are seeing the CLK line but I2C Transmit is getting hung there--

ret = I2C_transmit(SLAVE_ADDR, _txBuffer, 4);

Let me know your thoughts on this.

regards

Ravi

     

RShiv.1
RShiv.1Author
Associate III
November 22, 2022

Hi,

when I ran the clock_streched using HAL_drivers...went inside the HAL_I2C_IsDeviceReady

I found that the code enter into if statement of HAL_state_ready but after that the I2C waits for waitonflaguntiltimeout...here HAL_returns busy and thats why we are getting failure..any pointers here..

The address used here is 0x61 <<1 ..also tried with 0x30 << 1...The device address as per document is 0x61...Let me know your thoughts..

thanks and regards

Ravi

RShiv.1
RShiv.1Author
Associate III
November 22, 2022

I also added printf's inside I2C already ready if loop and also in do ..while loop but the code is not inside this...any configuration change in bit set let me know..thanks

RShiv.1
RShiv.1Author
Associate III
November 22, 2022

*code is not entering into these loops at all..that is why I2C is failing..that means is the address not specified properly??..or Need to enable something else...???