This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHCC3220MODASF: Unable to communicate with ds3231(I2C)

Part Number: LAUNCHCC3220MODASF


Hi,


We use external RTC ds3231 to get date and time. We are using default I2c library ti/drivers/I2C.c but while writing timing to DS3231 I experienced I2C transfer failed.
If I connect DS3231 to esp32 it works.

Procedures for regeneration

* Remove jumpers j14 and j15( ds3231 module has inbuilt I2c pull-up)
* Connect sda and scl lines from ds3231 to sda and scl line of launchpad
* The ds3231 is powered by 3.3v from the cc32200 launchpad
* Run the code below



      


void RTC_test( struct tm *timeInfo) {
  I2C_init();
    // Initialize I2C
    I2C_Handle i2cHandle;
    I2C_Params i2cParams;
    i2cParams.bitRate = I2C_400kHz ;
    I2C_Params_init(&i2cParams);
    i2cHandle = I2C_open(CONFIG_I2C_0, &i2cParams);
    if (i2cHandle == NULL) {
        // Handle error
        Display_printf(display, 0, 0,"Error initializing I2C\n");
        return;
    }
         // Prepare data to write
     uint8_t data[8];  // The first byte is the register address

     data[0] = DS3231_REG_ADDRESS ; // Start writing from address 0
     data[1] = dec2bcd(timeInfo->tm_sec);
     data[2] = dec2bcd(timeInfo->tm_min);
     data[3] = dec2bcd(timeInfo->tm_hour);
     data[4] = dec2bcd(timeInfo->tm_wday + 1);
     data[5] = dec2bcd(timeInfo->tm_mday);
     data[6] = dec2bcd(timeInfo->tm_mon + 1);
     data[7] = dec2bcd(timeInfo->tm_year - 100);

     // Write the time to DS3231
     I2C_Transaction writeTransaction = {
         .slaveAddress = DS3231_I2C_ADDRESS,
         .writeBuf = data,
         .writeCount = sizeof(data),
         .readBuf = NULL,
         .readCount = 0
     };

     if (!I2C_transfer(i2cHandle, &writeTransaction)) {
         // Handle error
         Display_printf(display, 0, 0,"Error writing time to DS3231\n");
         I2C_close(i2cHandle);
         return;
     }


Please help me resolve the issue