cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f10x -- ADS1115 -- I2C

Moha-Affa
Associate II
Posted on February 09, 2018 at 12:57

hello guys , i have a problem with the communication between STM32F103 and ADS1115 i have a very simple code ,which just establisch the connect but i always have the AF Flag set ... in the datasheet of ADS1115 the address is 1001000 when the ADDR pin is connected to GND and so it is in my case and one bit left shift means 10010000=0x90 . now when i generate start bit and then send the address the AF goes to '1' Acknowledge failure and thats mean the address doesnt match !!! any help would be appreciated . this is the code :

#include 'stm32f10x_conf.h'
 
#define ADS1115_Address 0x90 
int main(void){

 GPIO_InitTypeDef GPIO_InitStructure;
 I2C_InitTypeDef I2C_InitStructure;
 
 RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
 
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 GPIO_Init(GPIOB, &GPIO_InitStructure);
 
 GPIO_PinRemapConfig(GPIO_Remap_I2C1, ENABLE);
 
 I2C_DeInit(I2C1);
 
 I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
 I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
 I2C_InitStructure.I2C_ClockSpeed = 100000;
 I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
 I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
 I2C_InitStructure.I2C_OwnAddress1 = 0;
 I2C_Init(I2C1, &I2C_InitStructure);
 I2C_Cmd(I2C1, ENABLE);
 
 I2C_GenerateSTART(I2C1,ENABLE);
 
 I2C_Send7bitAddress(I2C1,0x90,I2C_Direction_Transmitter);

}

0 REPLIES 0