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.

MSP430F5529使用IIC驱动MPU6050失败

我们相同的硬件和相同的软件以前用没问题,但是现在会卡在IIC的写byte上。

当前的情况是可以读到MPU6050的寄存器数据,但是无法写入数据。

extern uint8 IICreadBytes(uint8 dev, uint8 reg, uint8 length, uint8 *data)
{
    uint8 ret = 0;
    uint8 i = 0;
    volatile static uint8 cnt = 0;

    cnt = 0;
    USCI_B_I2C_setSlaveAddress(USCI_B0_BASE, dev);

    if(USCI_B_I2C_masterSendMultiByteStartWithTimeout(USCI_B0_BASE, reg, IIC_TIMEOUT))
    {
        // Can't lack  会卡在这个地方
        while(!USCI_B_I2C_getInterruptStatus(USCI_B0_BASE, USCI_B_I2C_TRANSMIT_INTERRUPT))
        ;

        // Can't clear transmit interrupt here, will cause error!!!

        USCI_B_I2C_masterReceiveMultiByteStart(USCI_B0_BASE);

        for(i=0; i<length-1; i++)
        {
            cnt++;
            while(!USCI_B_I2C_getInterruptStatus(USCI_B0_BASE, USCI_B_I2C_RECEIVE_INTERRUPT))
            ;
            data[i] = USCI_B_I2C_masterReceiveMultiByteNext(USCI_B0_BASE);
        }

        while(!USCI_B_I2C_getInterruptStatus(USCI_B0_BASE, USCI_B_I2C_RECEIVE_INTERRUPT))
        ;
        cnt++;
        ret = USCI_B_I2C_masterReceiveMultiByteFinishWithTimeout(USCI_B0_BASE, &data[i], IIC_TIMEOUT);
     }

     return ret;
}

可以读到器件的WHO_AM_I器件地址,但是无法对其他寄存器写入。