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:无法与 ds3231 (I2C)通信

Guru**** 2483955 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1278725/launchcc3220modasf-unable-to-communicate-with-ds3231-i2c

器件型号:LAUNCHCC3220MODASF

您好!


我们使用外部 RTC ds3231来获取日期和时间。 我们正在使用默认 I2C 库 ti/drivers/i2c.c、但在将时序写入 DS3231时、我遇到了 I2C 传输失败。
如果我将 DS3231连接到 esp32、则可以正常工作。

再生程序

*移除跳线 J14和 J15 ( ds3231模块具有内置 I2C 上拉)
*将 sda 和 scl 线从 ds3231连接到 launchpad 的 sda 和 scl 线
* ds3231由 cc32200 launchpad 的3.3V 电源供电
*运行下面的代码



    


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;
     }


请帮助我解决此问题

 

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    您能解释一下您收到了什么错误吗? 或者根本没有看到传输发生?

    此致、

    罗格利奥