- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Rakshith M B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Rakshith M B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rakshith,
This was the magic I needed. Wasn't sure when to issue a Start vs Restart.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad it helped!
Regards,
Rakshith
Rakshith M B