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.

[参考译文] MSP430FR2433:I2C SCL 信号如何工作?

Guru**** 2482105 points


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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1259071/msp430fr2433-how-does-the-i2c-scl-signal-work

器件型号:MSP430FR2433

在查看"eusci_b_i2c_ex3_masterTxMultiple"示例时、我对 I2C 时钟信号的工作原理有几个问题。

此处是初始化 I2C 模块和 SMCLK 的代码、用于生成 I2C 时钟信号。

根据我的理解、I2C 时钟信号在此示例中源自 SMCLK 信号(因为我们在 I2C 模块初始化期间将 SMCLK 指定为源)、但我们单独初始化 SMCLK 信号和 I2C 时钟信号、是否正确?

换句话说、我们将 SMCLK 信号频率设置为1MHz、但当我们初始化 I2C 模块时、我们使用 param.datarate 将 I2C 时钟频率设置为其他某个(必须更低)值、正确吗?

    //Set DCO FLL reference = REFO
    CS_initClockSignal(
            CS_FLLREF,
            CS_REFOCLK_SELECT,
            CS_CLOCK_DIVIDER_1
        );

    //Set Ratio and Desired MCLK Frequency and initialize DCO
    CS_initFLLSettle(
            CS_SMCLK_DESIRED_FREQUENCY_IN_KHZ,
            CS_SMCLK_FLLREF_RATIO
            );

    //Set ACLK = VLO with frequency divider of 1
    CS_initClockSignal(
            CS_ACLK,
            CS_VLOCLK_SELECT,
            CS_CLOCK_DIVIDER_1
            );

    //Set SMCLK = DCO with frequency divider of 1
    CS_initClockSignal(
            CS_SMCLK,
            CS_DCOCLKDIV_SELECT,
            CS_CLOCK_DIVIDER_1
            );

    //Set MCLK = DCO with frequency divider of 1
    CS_initClockSignal(
            CS_MCLK,
            CS_DCOCLKDIV_SELECT,
            CS_CLOCK_DIVIDER_1
            );

    // Configure Pins for I2C
    GPIO_setAsPeripheralModuleFunctionInputPin(
        GPIO_PORT_UCB0SCL,
        GPIO_PIN_UCB0SCL,
        GPIO_FUNCTION_UCB0SCL
    );
    GPIO_setAsPeripheralModuleFunctionInputPin(
        GPIO_PORT_UCB0SDA,
        GPIO_PIN_UCB0SDA,
        GPIO_FUNCTION_UCB0SDA
    );

    /*
     * Disable the GPIO power-on default high-impedance mode to activate
     * previously configured port settings
     */
    PMM_unlockLPM5();

    EUSCI_B_I2C_initMasterParam param = {0};
    param.selectClockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK;
    param.i2cClk = CS_getSMCLK();
    param.dataRate = EUSCI_B_I2C_SET_DATA_RATE_100KBPS;
    param.byteCounterThreshold = 0;
    param.autoSTOPGeneration = EUSCI_B_I2C_NO_AUTO_STOP;
    EUSCI_B_I2C_initMaster(EUSCI_B0_BASE, &param);

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

    可以。 SMCLK 通常用于许多外设、因此您需要了解它的运行速度。  

    I2C 时钟(实际上是 EUSCI 时钟- UART 和 SPI 也是如此)使用 BRW 寄存器中的整数分频数从源时钟(在您的情况下是 SMCLK)分频。 driverlib 调用似乎可以设置所需的任意(I2C)时钟速度、但只能得到 SMCLK 的整数商。  

    driverlib 通过 i2cClock/datarate 除以计算 BRW;上次我查看它做了截断除法、如果它不均匀除法、时钟的运行速度会比你要求的要快。 (1MHz 可以使用100kHz、但1MHz 可以使用400kHz。)