2022-11-18 06:00 AM
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
Solved! Go to Solution.
2022-11-21 03:41 AM
>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 ?
in Cube ->
and adress is ok ? 7-bit , need shift left in HAL calls.
2022-11-21 03:50 AM
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
2022-11-21 04:08 AM
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
2022-11-21 05:32 AM
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
2022-11-21 05:50 AM
2022-11-21 05:54 AM
2022-11-21 09:18 AM
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.
2022-11-21 06:49 PM
Hi,
As said earlier the result with respect to SDA and SCL lines are as below
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
2022-11-21 10:25 PM
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
2022-11-21 10:29 PM
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