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.

MSP430169硬件IIC调式ADS1115读数错误????

Other Parts Discussed in Thread: MSP430F169, ADS1115

程序如下

#include <msp430f169.h>
#include"Init_clk.h"
#include"cryfuncs.h"
#include"ADS1115.h

void main( )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
Init_clk();
Ini_Lcd(); //LCD初始化
showADS1115();

P3SEL |= 0x0A;                            // Select I2C pins
U0CTL |= I2C + SYNC;              // Recommended init procedure
U0CTL &= ~I2CEN;                    // Recommended init procedure
I2CTCTL |= I2CSSEL1;             // SMCLK, transmit
I2CNDAT = 0x03;                      // Write Three bytes
I2CSA = 0x48;                           // Slave Address is 1001000
U0CTL |= I2CEN;                     // Enable I2C

Confige_1115(0); //通道选择
while(1)
{

Point_reg(); 
value=Read_1115(); 
}

}

/**************************************************************************************************/

void Confige_1115(uchar channel )
{
uchar chan;
switch(channel)
{
case 0: chan = 0xc4; break;//11000100
case 1: chan = 0x52; break;//01010010
case 2: chan = 0x62; break;//01100010
case 3: chan = 0x72; //01110010
}
U0CTL |= MST;                                           // Master mode
I2CTCTL |= I2CSTT+I2CSTP+I2CTRX; // Initiate transfer
//I2CNDAT = 0x03;
while ((I2CIFG & TXRDYIFG) == 0);      // Wait for transmitter to be ready
I2CDRB = 0x01;                                        // Points to config register
while ((I2CIFG & TXRDYIFG) == 0);     // Wait for transmitter to be ready
I2CDRB = chan;                                       // Load Control Byte
while ((I2CIFG & TXRDYIFG) == 0);     // Wait for transmitter to be ready    /***之前还会卡在这里,后来突然就好了,不得解****/
I2CDRB = 0x83;                                       // Load Control Byte
while ((I2CTCTL & I2CSTP) == 0x02); // To prevent Arbitration Lost
}

/**********************************************************************************************/

uint Read_1115(void)
{
float Voltage;
uint ctlbyte;

U0CTL |= MST;                                      // Master mode
I2CTCTL = I2CSTT+I2CSTP;              // Initiate transfer
I2CNDAT = 0x02;  
while ((I2CIFG & RXRDYIFG) == 0); // Wait for Receiver to be ready
ctlbyte = I2CDRB;                                 // Receive MSByte from DAC
ctlbyte = ctlbyte << 8;
while ((I2CIFG & RXRDYIFG) == 0); // Wait for Receiver to be ready
ctlbyte = ctlbyte + I2CDRB;                  // Receive LSByte from DAC
while ((I2CTCTL & I2CSTP) == 0x02); // Wait for Stop Condition

Voltage=ctlbyte*2.048/32768;
Disp_float_num(1,2,Voltage);

return ctlbyte;
}

/****************************************************************************************************/

void Point_reg(void)
{
U0CTL |= MST;                                           // Master mode
I2CTCTL |= I2CSTT+I2CSTP+I2CTRX; // Initiate transfer
I2CNDAT = 0x01;
while ((I2CIFG & TXRDYIFG) == 0);       // Wait for transmitter to be ready
I2CDRB = 0x00; // Points to conversin register
while ((I2CTCTL & I2CSTP) == 0x02);  // Wait for Stop Condition
}

/*************************************************************************************/

void showADS1115(void)
{
Send(0,0x01); /*清屏,将DDRAM的位址计数器调整为“00H”*/
Disp_HZ(0x80,"A=",1);
}

为什么会读不了数??求救QAQ

AIN0什么都不接,读数是4398 接了一个直流电源以后就会不停地跳数但是没有一个对的

而且不论直流电源有没有输出都会跳,为什么?