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.

TMS320F28035: 如何在已经挂载EEPROM的F28034的I2C上面挂载SHT3X,做到一次性读取SHT3X发送的6个字节的数据?

Part Number: TMS320F28035


您好,我使用的是TI C2000的F28034,我的I2C上面已经挂载了一个EEPROM,现在需要再在I2C上面挂载一个温湿度传感器。原本的代码框架在使用的过程中,一次I2C传输,最大可以接受四个字节的数据。但是,我们现在采用的温湿度传感器,他是发送一个命令后,会一次性发送6个字节的数据让DSP接受,但是我接受不到,我也想了些办法,也是没有成功,我想问一下,有什么方式,可以使用DSP的代码框架下读取6个字节吗,我需要修改哪些部分,但是又不能影响到原来的EEPROM的读写?请问有什么方法吗?需要修改什么配置吗?还是只能使用硬件模拟

  • 可是他的是发送,我现在是需要接受数据,需要修改什么吗

  • __interrupt void
    i2c_int1a_isr(void)
    {
        Uint16 IntSource, i;
    
        //
        // Read interrupt source
        //
        IntSource = I2caRegs.I2CISRC.all;
    
        //
        // Interrupt source = stop condition detected
        //
        if(IntSource == I2C_SCD_ISRC)
        {
            //
            // If completed message was writing data, reset msg to inactive state
            //
            if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_WRITE_BUSY)
            {
                CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_INACTIVE;
            }
            else
            {
                //
                // If a message receives a NACK during the address setup portion
                // of the EEPROM read, the code further below included in the
                // register access ready interrupt source code will generate a stop
                // condition. After the stop condition is received (here), set the
                // message status to try again. User may want to limit the number
                // of retries before generating an error.
                //
                if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
                {
                    CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_SEND_NOSTOP;
                }
               
                //
                // If completed message was reading EEPROM data, reset msg to
                // inactive state and read data from FIFO.
                //
                else if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_READ_BUSY)
                {
                    CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_INACTIVE;
                   
                    for(i=0; i < I2C_NUMBYTES; i++)
                    {
                        CurrentMsgPtr->MsgBuffer[i] = I2caRegs.I2CDRR;
                    }
                   
                    {
                        //
                        // Check received data
                        //
                        for(i=0; i < I2C_NUMBYTES; i++)
                        {
                            if(I2cMsgIn1.MsgBuffer[i] == I2cMsgOut1.MsgBuffer[i])
                            {
                                PassCount++;
                            }
                            else
                            {
                                FailCount++;
                            }
                        }
                       
                        if(PassCount == I2C_NUMBYTES)
                        {
                            pass();
                        }
                       
                        else
                        {
                            fail();
                        }
                    }
                }
            }
        }
    
        //
        // Interrupt source = Register Access Ready
        // This interrupt is used to determine when the EEPROM address setup
        // portion of the read data communication is complete. Since no stop bit is
        // commanded, this flag tells us when the message has been sent instead of
        // the SCD flag. If a NACK is received, clear the NACK bit and command a
        // stop. Otherwise, move on to the read data portion of the communication.
        //
        else if(IntSource == I2C_ARDY_ISRC)
        {
            if(I2caRegs.I2CSTR.bit.NACK == 1)
            {
                I2caRegs.I2CMDR.bit.STP = 1;
                I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT;
            }
            else if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
            {
                CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_RESTART;
            }
        }  
       
        else
        {
            //
            // Generate some error due to invalid interrupt source
            //
            __asm("   ESTOP0");
        }
    
        //
        // Enable future I2C (PIE Group 8) interrupts
        //
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
    }
    我使用的是官方的读取方式,在计数器到技术完毕,会发生一个NCK,NCK载触发STP,然后再读取数据,可是当我的计数设置为6的时候,根本减不完成,我想着提前读取,尝试了几次还是失败,

  • 给您发的链接中主要想表达的意思是您需要尝试不使用FIFO,因为影响您发送/接收字节受限主要是因为FIFO最多还能发送和接收4字节。

    官方没给不使用FIFO的示例或者指南,只是给了建议。

    e2e.ti.com/.../ccs-tms320f28075-how-to-use-i2c-without-fifo-function

  • 没有不使用FIFO的案例代码吗

  • 那我如果关闭FIFO的话,我的发送和读取软件代码是否都需要改变,还有,如果我关闭FIFO的话,会对我的EEPROM有什么影响吗?我可以在读取EEPROM的时候选择FIFO模式,在读取温湿度数据的时候关闭FIFO吗

  • 您好,如果我关闭了FIFO,我改如何读取数据,在案例中,是  if(IntSource == I2C_SCD_ISRC)才会进行读取,而要触发这个条件,需要使用NACK产生停止信号,可是我不知道如何控制他产生NACK,或者在NACK之前就读取数据

  • 您好

    1)官网没有相关demo。

    2)发送和接收都需要改变,最基本的I2CFFTX I2CFFRX都应该设置为disable。如果您关闭FIFO,其他不做更改,您的EEPROM的IIC应该会不好用。理论上可以。

    3)看一下这款芯片的TRM手册(https://www.ti.com.cn/cn/lit/ug/sprui10a/sprui10a.pdf )的IIC部分, 更多细节上的内容,建议您到英文论坛发帖咨询资深工程师:https://e2e.ti.com/p/addpost