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.

280049 I2C控制TCA9539 丢失STOP位

Other Parts Discussed in Thread: TCA9539

Dear TI,

使用280049的I2C模块和TCA9539(IO扩展)芯片进行通信。

当波特率设置到100kHz时,观察波形发现进行一段时间正常通信后,会出现无数据/无时钟的情况。

如果把波特率设置到50/10kHz,通信会一直正常,波形也正确。

具体问题是,在TCA9539发送了IO信息后,280049的I2C芯片应该先产生一个NACK位,再产生一个STOP来结束本次读取过程。出问题的时候,280049在发送了NACK位后,没有产生STOP位,反而产生了RESTART位,导致和TCA9539时序不匹配。

  • 你好,我需要一点时间确认这个问题的原因,还请耐心等待。
  • 希望能迅速听到您的回应。
  • F280049中的I2C模块不会产生START条件/repeated START条件,除非I2CMDR.STT = 1被置位。
    根据故障描述,好像程序没有在等待先前的读取任务完成。 使用轮询方法时,需要等待STOP条件生成,然后再设置I2CMDR.STT = 1。
    在代码中,设置I2CMDR.STT = 1之前要确保等待I2CMDR.STP被清除。 简而言之,在确保清除I2CMDR.STP之前,切勿设置I2CMDR.STT。
  • 实际情况是刚开始是能以正确的时序进行读取的。

    Uint16 I2CwriteData(volatile struct I2CMsg *msg)
    {
        Uint16 i;
    
        //
        // Wait until the STP bit is cleared from any previous master
        // communication. Clearing of this bit by the module is delayed until after
        // the SCD bit is set. If this bit is not checked prior to initiating a new
        // message, the I2C could get confused.
        //
        if(I2C_getStopConditionStatus(I2CA_BASE))
        {
            return(ERROR_STOP_NOT_READY);
        }
    
        //
        // Setup slave address
        //
        I2C_setSlaveAddress(I2CA_BASE, SLAVE_ADDRESS);
    
        //
        // Check if bus busy
        //
        if(I2C_isBusBusy(I2CA_BASE))
        {
            return(ERROR_BUS_BUSY);
        }
    
        //
        // Setup number of bytes to send msgBuffer and address
        //
        I2C_setDataCount(I2CA_BASE, (msg->numBytes + 1));
    
        //
        // Setup data to send
        //
        I2C_putData(I2CA_BASE, msg->RegAddr);
    
        for (i = 0; i < msg->numBytes; i++)
        {
            I2C_putData(I2CA_BASE, msg->msgBuffer[i]);
        }
    
        //
        // Send start as master transmitter
        //
        I2C_setConfig(I2CA_BASE, I2C_MASTER_SEND_MODE);
        I2C_sendStartCondition(I2CA_BASE);
        I2C_sendStopCondition(I2CA_BASE);
    
        return(I2C_SUCCESS);
    }

    发送函数如上,根据例程修改的。放在主函数中循环运行。

    上面一共是两个问题:1.为什么置位了STP没有正常发送;2.为什么会重新START;

    主要关注点在1,我想问I2C在什么情况下会不发送STOP到总线上(STP已经置位的情况下)?是否和I2CSTR.SCD位有关?

  • 你好,看到你在E2E论坛上有回复过了,还请继续跟进E2E帖子:
    e2e.ti.com/.../tms320f280049-tca9539-lost-stop-bit