3 Replies Latest reply on Sep 14, 2020 6:37 AM by RakshithM_16

    Problem talking to MCP79410 Real Time Clock (RTC) over I2C

    RIWe_4763466

      I'm new to PSoC, and am having trouble talking to an external RTC chip over I2C.

       

      I have created a Random Read Byte function for the RTC:

       

      1  unsigned char READ_I2C(unsigned char Slave_Add,unsigned char Addr_Byte) {

      2     uint32 err; // error state or status

      3     unsigned char rdByte;

      4     err = RTCC_I2CMasterStatus();

      5     err = RTCC_I2CMasterSendStart(Slave_Add, RTCC_I2C_WRITE_XFER_MODE, 0);

      6     err = RTCC_I2CMasterWriteByte(Addr_Byte, 0);

      7     err = RTCC_I2CMasterSendStart(Slave_Add, RTCC_I2C_READ_XFER_MODE, 0);

      8     err = RTCC_I2CMasterReadByte(RTCC_I2C_NAK_DATA, &rdByte, 0);

      9     return rdByte;

      10 }

       

      This is intended to produce the following I2C sequence as given in the RTC datasheet

       

      Looking at this on an analyzer, I see the following (which looks good up until the START of the Read).

      There is indeed a Write of the CONTROL BYTE + ACK followed by the ADDRESS BYTE (0) + ACK.

      Inspection of err is always 0 down to line 7.  But when I try to issue a SendStart of a Read, I get a return code of 4 (RTCC_I2C_MSTR_NOT_READY).

      Looking deeper, this is because the RTCC_state is not idle (it is still RTCC_I2C_FSM_MSTR_WR_DATA).

       

      Any idea of what might be wrong?