PsoC4 Interfacing with DS3231 (RTC)

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

cross mob
AsRa_264661
Level 4
Level 4
50 replies posted 25 replies posted 10 likes received

Dear all,

   

I am using CY8CKIT-049-42xx kit to interface with my DS3231 RTC module via I2C,

   

I tried to initialize the RTC by the following code but did not works, i am not sure about this I2C communication,

   

please help me , if any example code or project is avilable?

   

  I2CM_I2CMasterSendStart(I2C_SLAVE_ADDR,I2CM_I2C_WRITE_XFER_MODE);
    I2CM_I2CMasterWriteByte(0x00);// 00H register
    I2CM_I2CMasterWriteByte(0x00);// sec
    I2CM_I2CMasterWriteByte(0x00);// min
    I2CM_I2CMasterWriteByte(0x00);// hrs
    I2CM_I2CMasterWriteByte(0x01);// day
    I2CM_I2CMasterWriteByte(11); // day
    I2CM_I2CMasterWriteByte(12);//month
    I2CM_I2CMasterWriteByte(16);//year
    I2CM_I2CMasterSendStop();

   

Thanks,

   

Ashok R

0 Likes
2 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Which I2C_SLAVE_ADDR do you use?

   

Keep in mind that most of the APIs (except those for reading a byte) return a status byte which, when non-zero indicates an error condition.

   

 

   

Bob

0 Likes
AsRa_264661
Level 4
Level 4
50 replies posted 25 replies posted 10 likes received

Hi Bob,

   

I used 0x68 as I2C_SLAVE_ADDRESS

   

And looks like now working, some connection issues.

   

Thanks,

   

Ashok r

0 Likes