I am using stm8s controller and SDCC compiler. I am interfacing SD130S7 I2C based RTC with controller. I am facing a problem during communication. I think the problem is I2C itself is not started.
I am using a development board for STM8S103.
I checked on logic analyser and i see there is only one pulse on SDA pin.
I am confused how come SDA has pulse and SCL doesn't. (As SCL is clock and Clock should be present at first).
void init_i2c_master(void)
{
CLK_PCKENR1 |= 0x01; //enable i2c clocks
I2C_CR1 &= ~(0x01); //Disable the i2c before configuration starts
I2C_FREQR = 16;// Set the internal clock 16 frequency (MHz).
I2C_OARH = 0xC0; //set 7 bit addressing mode
I2C_TRISER = 16 + 1;
I2C_CCRL = (uint8_t)(16*5);
I2C_CCRH = 0;
I2C_CR1 |= 0x01; //enable i2c peripheral
I2C_CR2 |= 0x04;
I2C_CR2 &= ~0x08;
I2C_ITR |= (0x01 | 0x02);
}