Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Working with Ads1015 I2C interface is having some problem

Status
Not open for further replies.

shubh1196

New Member
Hello there,
I'm trying to access the Mics-6814 sensor with Ads1015 ADC, as this ADC communicates with the I2c protocol.
Here is the step we need to follow to get the I2C communication working, as per the datasheet-
For writing--
1. On sending the device address from UC my sensor address is getting acknowledged
2. Now we need to write to config-register, for which we need to send its address pointer i.e 0x01,
3. On accessing the same address we will be getting the acknowledgment,
4. After that, we need to send 2 bytes of config data to be saved.

But I'm facing the problem in performing the 3rd step, that instead of getting the acknowledgment after the 9th bit, I'm getting a HIGH bit after 8th bit, you can see this in the attached image.
And adding the ADC datasheet and my I2c code can anyone help me in finding from where this 1 bit is becoming high. i2c_ahrq58.png
void I2C1_gpio_init()
{
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
RCC_I2CCLKConfig(RCC_I2C1CLK_HSI);
GPIO_InitTypeDef GPIO_InitStructure;

GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_1);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_1);

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; //GPIO_OType_PP
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //GPIO0_PuPd_UP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}

void I2C1_init()
{
I2C_InitTypeDef I2C_InitStructure;
I2C_InitStructure.I2C_Timing = 0x2000090E;
I2C_InitStructure.I2C_AnalogFilter = I2C_AnalogFilter_Enable;
I2C_InitStructure.I2C_DigitalFilter = 0x00;
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
I2C_InitStructure.I2C_OwnAddress1 = 0x00;
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
I2C_Init(I2C1,&I2C_InitStructure);
I2C_Cmd(I2C1, ENABLE);
I2C_AutoEndCmd(I2C1, ENABLE);
}
 

Attachments

  • ads1015.pdf
    1.5 MB · Views: 230
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top