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

63 REPLIES 63
RShiv.1
Senior

checked with CRC 0xC2..not seeing any change

AScha.3
Chief II

yea.

If you feel a post has answered your question, please click "Accept as Solution".
RShiv.1
Senior

any other methods to get this???

RShiv.1
Senior

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
Senior

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
Senior

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
Senior

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
Chief II

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

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
Senior

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..