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.

TMS470 通过 I2C 读取ADC1110里的数据

Other Parts Discussed in Thread: ADS1110

unsigned char adcp1; // ADC variable for Most Significant Byte
unsigned char adcp2; // ADC variable for Least Significant Byte
unsigned char config; // ADC variable for Configuration Register
void ADS1110_ReadVoltage(void)
{
//I2C 1 Set up
I2C1PSC = 2; // Module clock frequency
// I2CCLK = ICLK / (PSC + 1)
// I2CCLK = 10 MHz
I2C1CKL = 45; // Low clock period
I2C1CKH = 45; // High clock period
I2C1OAR = 0x56; // Set TMS470's Own address to 0x56
I2C1IMR = 0x0; // Interrupts disabled
I2C1CNT = 3; // Number of byte transactions between I2C Start and Stop
I2C1SAR = 0x48; // Set address of ADC to 0x48
I2C1PFNC = 0; // Pins function as SDA and SCL pins
I2C1DIR = SDAFUNC+SCLFUNC; // Set I2C Pin direction
I2C1MDR |= MST; // Make TMS470 addr 0x56 the IIC the Master
I2C1MDR |= NIRS; // Clear Reset
I2C1MDR &= ~TRX; // Clear transmit to Read
I2C1MDR |= STT + STP; // Start, Stop and Transmit
while(!(I2C1SR & 0x0008)); // Verify I2CDRR has been read
adcp1 = (I2C1DRR); // Capture Most Significant Byte First
while(!(I2C1SR & 0x0008)); // Verify I2CDRR has been read
adcp2 = (I2C1DRR); // Capture Least Significant Byte Second
while(!(I2C1SR & 0x0008)); // Verify I2CDRR has been read
config = (I2C1DRR); // Capture Configuration Register Value third
}

 

搞不懂为啥I2C1OAR = 0x56 的具体含义 求各路大神帮解答一下  最好说得很详细

  • I2C1OAR = 0x56; // Set TMS470's Own address to 0x56
    I2C1IMR = 0x0; // Interrupts disabled
    I2C1CNT = 3; // Number of byte transactions between I2C Start and Stop
    I2C1SAR = 0x48; // Set address of ADC to 0x48
    I2C1PFNC = 0; // Pins function as SDA and SCL pins
    I2C1DIR = SDAFUNC+SCLFUNC; // Set I2C Pin direction
    I2C1MDR |= MST; // Make TMS470 addr 0x56 the IIC the Master

    关键就是这几句:设置0x56,和下面设置ADC的地址是0x48,道理一样,是可以更改的,你这些给OAR(自己的地址)定义了个名字,这里就是0x56,就是给本地起了个编号地址0x56,后面最后一句就是让改地址设备作为IIC主机,同样设置ADC为0x48后,后面你再操作ADC就可以通过048进行了。

  • uint16* I2c_Page_Rx_single()
    {
      uint16 I2Cbuffer,i;
      int num=0;
          
             I2C2OAR = 0x00;
             I2C2IMR = 0x0;
             I2C2CNT = 16;
             I2C2SAR = 0x50;
             I2C2MDR |= MST;
             I2C2MDR |= NIRS;
             I2C2MDR &= ~TRX;
             I2C2MDR |= STT + STP;
                   for(i=0;i<16;i++)
            {
              while(!(I2C2SR & 0x0008));
              I2Cbuffer=I2C2DRR;
              printf("%d\r\n", I2Cbuffer);
            }

    这是我读取AT24C04的中的数据,AT24C04 有512个字节,32页,现在我想读取某一页的数据,在程序中I2C2SAR = 0x50   0x50是设备地址,接下来要给读具体哪一页的地址;到这里我就不知道怎么给它地址,你可以指导指导吗?