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

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
RIWe_4763466
Level 1
Level 1

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

pastedImage_2.png

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

pastedImage_4.png

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?

0 Likes
1 Solution
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi RIWe_4763466​,

Can you please try using RTCC_I2CMasterSendRestart() API instead of Start API and let me know if that helps?

You can refer to the component datasheet for information regarding the API. Additionally, you can use the CE222306 - PSoC 4 I2C Communication with Serial Comunication Block (SCB) as a reference.

Hope this helps,

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B

View solution in original post

0 Likes
3 Replies
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi RIWe_4763466​,

Can you please try using RTCC_I2CMasterSendRestart() API instead of Start API and let me know if that helps?

You can refer to the component datasheet for information regarding the API. Additionally, you can use the CE222306 - PSoC 4 I2C Communication with Serial Comunication Block (SCB) as a reference.

Hope this helps,

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B
0 Likes

Hi Rakshith,

This was the magic I needed.  Wasn't sure when to issue a Start vs Restart.

Thank you!

0 Likes

Glad it helped!

Regards,

Rakshith

Thanks and Regards,
Rakshith M B
0 Likes