cancel
Showing results for 
Search instead for 
Did you mean: 

I2C not working with STM32F103C6 and STM32F103C8

RShiv.1
Senior

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

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Chief III

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 "Accept as Solution".

View solution in original post

63 REPLIES 63
RShiv.1
Senior

attached is the code for C8 and apart from choosing C6 in cubemX rest all the code remains the same..

quick response will help us a lot..

thanks and regards

Ravi

RShiv.1
Senior

Hi all,

Any update on this ...we are trying it out and not getting any response..is it more to do with STMCube Mx generating I2C for I2C1 or Is there any solution with I2C2 .??...

if there is any bit banging code for this where we can try this out by making the I2C pins GPIO out...

All these possibilities shall be tried out ...Kindly let us know the approach as we are stuck at a point where STM32F103C6 or C8 needed to be used ....will be of great help if some one can respond .

thanks

Ravi

Imen.D
ST Employee

Hello @RShiv.1​ 

Did you tried to run the I2C example within STM32CubeF1 MCU package?

\Projects\STM32F103RB-Nucleo\Examples\I2C\

I advise you to review this article: STM32 I2C does not work and the I2C limitation in the STM32F103xC/D/E errata sheet.

Then, please have a look at this post and AN4655 which describes the steps to do I2C by SW.

Hope this helps you!

When your question is answered, please close this topic by choosing Select as Best.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Imen.D
ST Employee

Hi @RShiv.1​,

I added a couple of topics for: "STM32 MCUs" and "I2C" developers to give a broader audience of this post.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
RShiv.1
Senior

Hi ,

As suggested and also going through the other post I have done the bitbanging approach for the I2C.

Here also I am seeing I2C_Transmit not passsing through...kindly let me know where I can change in the code for I2C_Transmit...it just hangs after the first I2Cwrite...I am not seeing any data in the SDA line at all...Let me know if you need more information.

This is for connecting Sensor SCD30 with the STM32F103C6

RShiv.1
Senior

I am almost trying to get the SDC as follows

This is a sample code using adruino with libraries

Python code

from scd30_i2c import SCD30

scd30 = SCD30()

scd30.set_measurement_interval(2) //address is 0x4600

scd30.start_periodic_measurement() // 0x0010

time.sleep(2)

while True:

if scd30.get_data_ready(): 0x0202

m = scd30.read_measurement() // 0x0300

if m is not None:

print(f"CO2: {m[0]:.2f}ppm, temp: {m[1]:.2f}'C, rh: {m[2]:.2f}%")

time.sleep(2)

else:

time.sleep(0.2)

RShiv.1
Senior

SCD_30 interface description attached

RShiv.1
Senior

also attached is the stm32_sw_i2c .c file for ref...timely help would be appreciated..thanks

RShiv.1
Senior

      printf("B4 I2C \n");

     ret = I2C_transmit(SLAVE_ADDR, _txBuffer, 4); //I2C hangs here and not seeing the data go through the line

      printf("After I2C \n");