I have just picked up working with PSoC and went through the PSoC 101 Lessons to get the basics. Turning LEDs on and off got old quite fast so now I am trying to communicate with an RTC through I2C.
With the “automatic mode” I am getting results that I do not understand. With the “manual mode” I seem to be able to feed the RTC with some data but just can’t extract it back.
I am using PSoC Creator 3.1 SP3 with the CY8CKIT-049-42xx kit with the corresponding CyInstaller.
The RTC is a no-name DS1307 bought on eBay (I2C address = 0b1101000).
10k pullups are installed on the I2C lines, with the 32khz xtal for the RTC.
Nothing special in the header:
I’ll start with the “manual mode” since this yields the most understandable results. Most if not all of the code I use for the communication comes straight from the I2C SCB datasheet from Cypress.
(refering to screeshot write_manual.png) The RTC ACKs when called and fed with 8 bytes of data. Looking good so far…
Afterwards, I read the first 8 registers in the RTC using the “manual mode”
Here the RTC returns random values for subsequent read operations: (refering to screenshot read_manual.png)
Some returned values event have ones in places where there should be a 0 according to the datasheet.
I am missing something here?
Now, if try to do the same with the “automatic mode”, even writing data does not seem to work. (The pinLedx here in the code are some LEDs that light up on the breadboard to help debug the code so I know where it’s stuck or not reaching.)
Here too, the RTC ACKs the address call, but the PSoC stays mute afterwards. It even appears as if it keeps the clock low and never puts it back up (even 5 seconds to the right of this screenshot, the clock stays low). (refering to screeshot write_auto.png)
The LED#2 is kept lit which tells the program is stuck in the following loop.
If I comment out this verification and only add a delay to let the transfer to complete, I get exactly the same thing: The PSoC master calls the RTC address, gets the ACK and then keeps the clock low permanently.
Now, if I comment out the “write” portion of this program and only “read” the registers upon start in the RTC
here is what I get:(refering to screeshot read_auto.png)
Still, the clock looks like it stuck on “low” after the last byte.
Here too, I have to comment out the loop that checks the master status for a complete flag otherwise it never comes out of it (the LED3 stays on). I am guessing that the status never reaches COMPLETE since the stop command is never issued, because the clock is stuck low.
Thank you guys,