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.

AMC7812B采集电压



我想使用amc7812b的16个通道进行ADC转换,如下是我对amc7812b芯片寄存器的一些配置,已经确认过读写寄存器没有问题,按照手册的说明应该是一直转换的,可是我给通道0一个1.8v的电压,然后去读取数据寄存器,发现里面的数据都是0,没有转换。为什么??寄存器的配置不对吗?

status_t AMC7812b_RT_Init(amc7812b_rt_handle_t *handle, LPI2C_Type *base)
{
    status_t status;
 assert(base);

    if (!base)
    {
        return kStatus_InvalidArgument;
    }

    handle->base = base;
 status = AMC7812b_RT_Write(handle, AMC7812B_CONFIG_REGISTER0, 0x2400);
 status = AMC7812b_RT_Write(handle, AMC7812B_Temperature_CONFIG_REGISTER, 0x00ff);
 status = AMC7812b_RT_Write(handle, AMC7812B_CHANNEL0_REGISTER, 0x6dff);
 status = AMC7812b_RT_Write(handle, AMC7812B_CHANNEL1_REGISTER, 0x7000);
 status = AMC7812b_RT_Write(handle, AMC7812B_CONFIG_REGISTER1, 0x0070);
 status = AMC7812b_RT_Write(handle, AMC7812B_CONFIG_REGISTER0, 0x3400);
    return status;
}

//调用函数读取数据寄存器0

AMC7812b_RT_Read(&amc7812b_Handle, AMC7812B_DATA0_REGISTER);
 for(int i=0; i<2; i++)
 {
  PRINTF("%2x", amc7812b_Handle.data_buf[i]);
 }
 PRINTF("\r\n");

status_t AMC7812b_RT_Write(amc7812b_rt_handle_t *handle, uint32_t register_address, uint16_t data)
{
 uint8_t mode[2];
 lpi2c_master_transfer_t *xfer = &(handle->xfer);
    status_t status;

    assert(handle);

    if (!handle)
    {
        return kStatus_InvalidArgument;
    }

    /* clear transfer structure and buffer */
    memset(xfer, 0, sizeof(*xfer));
    memset(handle->data_buf, 0, AMC7812b_RT_DATA_LEN);

 mode[0] = 0xff & (data>>8);
 mode[1] = 0xff & (data>>0);
 handle->xfer.slaveAddress = AMC7812B_RT_I2C_ADDRESS;
 handle->xfer.direction = kLPI2C_Write;
 handle->xfer.subaddress = register_address;
 handle->xfer.subaddressSize = 1;
 handle->xfer.data = mode;
 handle->xfer.dataSize = 2;
    handle->xfer.flags = kLPI2C_TransferDefaultFlag;
    status = LPI2C_MasterTransferBlocking(handle->base, &handle->xfer);
 return status;
}

status_t AMC7812b_RT_Read(amc7812b_rt_handle_t *handle, uint32_t register_address)
{
 status_t status;
    assert(handle);

    if (!handle)
    {
        return kStatus_InvalidArgument;
    }
 memset(handle->data_buf, 0, AMC7812b_RT_DATA_LEN);
 handle->xfer.slaveAddress = AMC7812B_RT_I2C_ADDRESS;
 handle->xfer.direction = kLPI2C_Read;
 handle->xfer.subaddress = register_address;
 handle->xfer.subaddressSize = 1;
 handle->xfer.data = handle->data_buf;
 handle->xfer.dataSize = 2;
    handle->xfer.flags = kLPI2C_TransferDefaultFlag;
    status = LPI2C_MasterTransferBlocking(handle->base, &handle->xfer);
 return status;
}