0

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);
}
Clifford
  • 88,407
  • 13
  • 85
  • 165
dev_eng
  • 126
  • 1
  • 12
  • The code you have posted in initialisation only - SCL is only active during bus transactions. – Clifford Nov 10 '19 at 09:21
  • You might do better to use the STM8 Standard Peripheral Library https://www.st.com/en/embedded-software/stsw-stm8069.html or at least inspect its code. It include examples. If the "known good" code does not work, then it is likely not a software issue. – Clifford Nov 10 '19 at 09:39
  • on my development board i noticed that it is connected one active low led which is connected on I2C_SDA pin. May be because of this i don't get signal. But is it really reason behind i2c failure? i am getting lots of error while using STM8s standard library. i think due missing correct path. – dev_eng Nov 16 '19 at 11:24

0 Answers0