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
AScha.3
Chief III

>it just hangs after the first I2Cwrite.

from SCD_30 ds can see, sensor need clock-stretching after first write. ->

so: you have clock-stretching enabled ?

0693W00000WJ2EaQAL.pngin Cube ->

0693W00000WJ2DrQAL.pngand adress is ok ? 7-bit , need shift left in HAL calls.

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

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
Senior

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
Senior

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
Senior

HAL_Isdevice_ready with is not passing through

RShiv.1
Senior

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

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

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
Senior

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
Senior

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