cancel
Showing results for 
Search instead for 
Did you mean: 

F103C6T6A i2c doesn't send start

Stequila93
Associate II

Hello,

I was working with i2c on a f103c6t6a a couple of months ago and it was working.

Now i just update stmcube ide to last version and i cannot get it work again.. (had a problem with gpio settings in past).

What i dont get is:

trying to use HAL_I2C_IsDeviceReady() doesn't seems to work and i always get error 512 a time out waiting SB flag to be set.

So i get stucked there where it keep waiting for SB flag but never comes up.

It sets bit 8 in CR1 and then nothing.

if(HAL_I2C_IsDeviceReady(&hi2c1, (0x40 << 1) , 2, 100) == HAL_OK){ 
       HAL_Delay(10);
}

SET_BIT(hi2c->Instance->CR1, I2C_CR1_START);
 
/* Wait until SB flag is set */
 if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_SB, RESET, Timeout, tickstart) != HAL_OK)
{
    if (READ_BIT(hi2c->Instance->CR1, I2C_CR1_START) == I2C_CR1_START)
{
     hi2c->ErrorCode = HAL_I2C_WRONG_START;
}
     return HAL_TIMEOUT;
}

I checked with an other device if the ina219 was working and i got response on its address.

Reading from reference manual start should be

Setting the START bit causes the interface to generate a Start condition and to switch to

Master mode (MSL bit set) when the BUSY bit is cleared.

it doesn't switch to master mode and if busy bit refer to bit 2 in SR2 is clear.

I don't understand what is changed from 2 months ago to make it not working.

Thanks

2 REPLIES 2
Stequila93
Associate II

Errata seems to not solve it.

Hi,

It would appear that I have the same problem, (with a STM32F103C8).

I have tried my darndest, and I have other MCUs ESP32, Pico W on the same line that works well, so it shouldn't be any pull-up stuff or anything else hardware related.

I get stuck in exactly the same place with the same error.

@Stequila93​ Have you found a solution?