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.

  • Resolved

ADS1115: ADS1115 not responding for the address 0x48

Prodigy 230 points

Replies: 16

Views: 311

Part Number: ADS1115

hello everybody,

I am interfacing ADS1115 with Nuvoton N76E003 using I2C.

I am using adc channel A0 and 5V suppy voltage.

I have connected ADDR pin of ADS1115 to GND.

When I am giving address 0x48 through master it gives 0x20 i.e.Master Transmit Address NACK as a reply.

so I am stuck here. Please find my attached code and suggest solution.

#define EEPROM_SLA 0x48
#define 	EEPROM_WR  0
#define     EEPROM_RD  1
#define SET_BIT3        0x08
#define SET_BIT4        0x10
#define P13_OpenDrain_Mode		P1M1|=SET_BIT3;P1M2|=SET_BIT3
#define P14_OpenDrain_Mode		P1M1|=SET_BIT4;P1M2|=SET_BIT4


#define I2C_ACK			0
#define I2C_NACK		1				 
#define timeout_count	1000
void INIT_I2C(void);
void ADS1115_config();
void ADS1115_read();
void I2C_start();
void I2C_stop();
void I2C_Master_Write(unsigned char value);
unsigned int I2C_Master_Read(unsigned short a);
void main()
{
	//MODIFY_HIRC_166();	
//---------------------I/O DEFINATION-----------------------------	
	
	//P1M1 = 0X80;	//FOR NORMAL PROGRAM

	
//----------------------FUNCTION CALLS----------------------------	
	
	INIT_I2C();
	I2C_start();
	ADS1115_config();
    ADS1115_read();
	 I2C_stop();
	while(1)
	{	     
    }
}

//----------------------------------I2C COMMUNICATION FOR DISPLAY--------------------------
void INIT_I2C(void)
{
	P13_OpenDrain_Mode;
	P14_OpenDrain_Mode ;
	SDA = 1;
	SCL = 1;
	I2CPX=0;  //SCL= P1.3 ,SDA=P1.4
	I2CEN=1;
	I2CLK=42;  //  400KBPS FOR 16MHZ CLOCK
}
//_________________________ADS1115 CONFIG AND DATA BLOCK_______________________//

void I2C_start(void)
{
	signed int t = timeout_count;
	
	STA = 1;                                
    SI = 0;
   
}

void I2C_stop(void)
{
	signed int t = timeout_count;
	
	SI = 0;
    STO = 1;    
}
void ADS1115_config()
{
 I2DAT = (EEPROM_SLA | EEPROM_WR);

 if(I2STAT == 0x18)
 {
 	LED = 1;
 }
 I2C_Master_Write(0x01);//Command to config registers    0x01
 I2C_Master_Write(0x80);//PGA: +-6.144V, Inputs: default (A0), continuous conv. mode		0x80
 I2C_Master_Write(0x83);//128 SPS, Traditional comparator, active low, nonlatching, dis. ALERT/RDY 	0x83
 
}
void I2C_Master_Write(unsigned char value)
{
 I2DAT = value; //Write data to SSPBUF
}
void ADS1115_read()
{
unsigned int datah;
unsigned int datal;

//float data;
I2C_Master_Write(0x90); 			//0x90
I2C_Master_Write(0x00); 			//0x00
I2C_Master_Write(0x91); 		   //0x91
datah = I2C_Master_Read(1);
datal = I2C_Master_Read(0);

}

unsigned int I2C_Master_Read(unsigned char ack_mode)
{
	signed int t = timeout_count;
	unsigned char value = 0x00;
	I2DAT = (EEPROM_SLA | EEPROM_RD);
	t = timeout_count;
	AA = 1;                             
    SI = 0;
    while((SI==0)&&(t>0)) 
	{
		t--;
	};   	
	
	value = I2DAT;

	if(ack_mode == I2C_NACK)
	{
		t = timeout_count;
		AA = 0;   
		SI = 0;
		while((SI == 0)&& (t>0)) 
		{
			t--;
		};   		
	}
	
	return value;

}

  • Hello,

    Can you please share a capture of the I2C communication waveforms using an oscilloscope?  Our ADS111x experts will get back with you early next week.

    Regards,
    Collin Wells
    Precision ADC Applications

  • In reply to Collin Wells:

    Gandhali,


    I would agree with Collin that you should use a logic analyzer or oscilloscope to look at the communication between the device and the microcontroller. Note that the communication should look exactly like the communication shown in figures 30 and 31 in the datasheet.

    Also, the registers in this device, including the config and conversion registers, are both 16 bits and are sent sequentially, while it looks like you are using 8 bit transactions for your write. Again, use the logic analyzer or oscilloscope to look at the I2C communication.


    Joseph Wu

  • In reply to Joseph Wu:

    Gandhali,


    A colleague just noticed that you've contructed the address read/write incorrectly. The I2C address is 48h, but that is the upper 7 bits of the write. In your address, you use 48h as the byte and then and OR it with 0 or 1 for a write or a read. For the I2C address, you should 90h and then OR it with 0 or the 1 for the write or read. From the timing diagram, you can see it here:




    Joseph Wu

  • In reply to Joseph Wu:

    hello Joseph,

    Thank you for your suggestion.

    I have written slave id 0x90 as per your suggestion but still its not responding.

  • In reply to Gandhali Joshi:

    Gandhali

    In that case, I think we need to see the SDA and SCL signals from an oscilloscope or logic analyzer. It is the best way to determine what the microcontroller is sending out and what the device is responding to.

    Get a scope shot and post it back here. Make sure there's enough detail to see the individual bits in the address and data.

    Joseph Wu

  • In reply to Joseph Wu:

    Gandhali,

    I haven't heard from you in a while, so I thought I'd check to see if you've solved your communication problem. In my last post, I suggested that you look at the communication with a scope or logic analyzer, and I think that's the best way to help debug these problems.

    I'll close this post for now, but if you are continuing to have problems, please post back and we can work on this again.

    Joseph Wu

  • In reply to Joseph Wu:

    hello sir,

    Actually I don't have logic analyzer and I am unable to capture images of waveforms on CRO.

    The problem is still there.

  • In reply to Gandhali Joshi:

    Gandhali,

    I think its very important to get a look at a scope shot of the ADC communications. Without this, it's impossible to know if the microprocessor is even sending out communication or commands to anything. Without this view, it's extremely difficult to debug these kind of problems.

    Joseph Wu

  • In reply to Joseph Wu:

    Hello Joseph,

    We have Tektronix TBS 1072B 70MHz digital oscilloscope and its difficult to capture shot on it.

    So should we run the program in a loop and then take a shot on it??

  • In reply to Gandhali Joshi:

    Gandhali,


    It should be fine to use that scope. Just use the scope to monitor the SDA and SCL lines on the ADS1115. Have it trigger on the first falling edge of the SCL line and see the following bytes come out.

    Make sure that you are able to read the bits directly. I would want to see enough detail to be able to read byte transactions completely.


    Joseph Wu

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.