STM32f10x - ADS1115 - I2C - 始终设置AF标志

问题描述 投票:1回答:1

当我发送地址时,我有一个问题是从ADS1115获得ACK。我使用Embitz IDE和STM32标准外设库。

我总是得到AF = 1。

这是代码:

#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);

    while(1) {
        I2C_GenerateSTART(I2C1, ENABLE);
        I2C_Send7bitAddress(I2C1, ADS1115_Address, I2C_Direction_Transmitter);
    }
}
c stm32 i2c
1个回答
-1
投票

ads1115只有4个地址0x48 0x49 0x4A 0x4B

您可以在数据表上找到寻址

你不能使用0x90地址广告1115

© www.soinside.com 2019 - 2024. All rights reserved.