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 24, 2022

I tried with the pattern I had used...but here I am not getting the version number also..

I had deliberately used delay in between...is this necessary..do you see any way there???

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

Hi ,

with this code atleast I got version number fine each time...with out CRC..but when I go ahead with periodic measurement...I see change in values...do not from where...

0693W00000WJQsKQAX.png

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

when I flash the previous code I shared with you ..I am able to get the version number..once I had any set interval or periodic measurement...version number values change and also ...periodic measurement fails...not able to understand where the probelm is??

let me know if you get any thought on this...almost close I guess..

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

Hi,

I changed the code where I coulf get the version number right..but when I read the get data ready..giving me same version number values..let me know where the problem is ??

0693W00000WJR0eQAH.png 

sometimes when I restart gives me ddddd values..do not know why??

AScha.3
Super User
November 24, 2022

me too :)

and i am sick...and cannot concentrate.

here the crc8 you need: (if chip refuses to work without crc byte)

> put gencrc() in your test program

and do:

  • start continous mode
  • in while...
  • wait for data ready stat
  • read data
  • < while

#include <stdio.h>
 
typedef unsigned char uint8_t;
 
uint8_t gencrc(uint8_t *data, size_t len)
{
 uint8_t crc = 0xff;
 size_t i, j;
 for (i = 0; i < len; i++) {
 crc ^= data[i];
 for (j = 0; j < 8; j++) {
 if ((crc & 0x80) != 0)
 crc = (uint8_t)((crc << 1) ^ 0x31);
 else
 crc <<= 1;
 }
 }
 return crc;
}
 
int main()
{
uint8_t data[8] = {0xBE,0xEF,0,0,0,0,0,0};
uint8_t crc;
 crc = gencrc(data, 2); /* returns 0x92 */
 printf("%1x\n", crc);
 crc = gencrc(data+2, 1); /* returns 0xac */
 printf("%1x\n", crc);
 return 0;
}

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

Hi ,

As suggested I generated the CRC and also the start continuous mode ..

looks like CRC is not generating as 9x92 instead getting 0x7d..any error let me know

I am getting data ready flag as 1.....

0693W00000WJV0SQAX.pngregards

Ravi

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

Hi,

I changed the code a bit ..here I am getting 0x92...but data available function has to return with set as 0x01...let me know if you get anything out of this..

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

Hi,

attached is the code where I am doing all measurement code..also..not getting the value...basically get ready flag itself fails...

regards

Ravi

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 ".
RShiv.1
RShiv.1Author
Associate III
November 26, 2022

Hi,

Finally worked!!!!!!!!!!!!!

I was actually referring to the first link only last time when I told you about the pattern..

as planned I only replaced/used the same flow...just replace and got working on STM32F103C8..attached is the zip file...this will also work for C6