Other Parts Discussed in Thread:PGA900, PGA305
我试图用I2C配置PGA900,我先后配置了
DIG_IF_CTRL |
MICRO_NTERFACE_CONTROL |
TEMP_CTRL |
ALPWR |
ADC_CFG_1 |
TADC_CONFIG |
但是在while中轮询读取
TADC_DATA1 |
TADC_DATA2 |
TADC_DATA3 |
全部是0x00,均没有数据,我用逻辑分析仪查看和i2c读配置的寄存器,都成功配置了,却没有数据
电路是自己做的,仿照pga305 page64
Kailyn Chen:
您好,数据是00还是FF?能否附上I2C的时序看下?是否收到ACK信号?
,
user4714975:
这个是ADC_Config验证寄存器是否配置成功,配置成功。
这个是在while中的读取TADC,返回为0x00
Init aTxBuffer[0] = 0x42; aTxBuffer[1] = 0x03; aTxBuffer[2] = 0x00; aTxBuffer[3] = 0x03; aTxBuffer[4] = 0x0F; aTxBuffer[5] = 0x02; aTxBuffer[6] = 0x30; aTxBuffer[7] = 0x04; aTxBuffer[8] = 0x11; aTxBuffer[9] = 0x14; HAL_I2C_Mem_Write(&hi2c1, ((0x20|0x02) << 1)|WREG, 0x06, I2C_MEMADD_SIZE_8BIT, &aTxBuffer[0], 1, 10);//Digital Interface Control HAL_I2C_Mem_Write(&hi2c1, ((0x20|0x00) << 1)|WREG, 0x0C, I2C_MEMADD_SIZE_8BIT, &aTxBuffer[1], 1, 10);//MICRO_INTERFACE_CONTROL HAL_I2C_Mem_Write(&hi2c1, ((0x20|0x02) << 1)|WREG, 0x67, I2C_MEMADD_SIZE_8BIT, &aTxBuffer[7], 1, 10);//AMUX_CTRL HAL_I2C_Mem_Write(&hi2c1, ((0x20|0x02) << 1)|WREG, 0x48, I2C_MEMADD_SIZE_8BIT, &aTxBuffer[5], 1, 10);//T_GAIN_SELECT HAL_I2C_Mem_Write(&hi2c1, ((0x20|0x02) << 1)|WREG, 0x4C, I2C_MEMADD_SIZE_8BIT, &aTxBuffer[6], 1, 10);//TEMP_CTRL HAL_I2C_Mem_Write(&hi2c1, ((0x20|0x02) << 1)|WREG, 0x29, I2C_MEMADD_SIZE_8BIT, &aTxBuffer[8], 1, 10);//ADC_CFG_1 HAL_I2C_Mem_Write(&hi2c1, ((0x20|0x02) << 1)|WREG, 0x50, I2C_MEMADD_SIZE_8BIT, &aTxBuffer[9], 1, 10);//ALPWR HAL_I2C_Mem_Write(&hi2c1, ((0x20|0x02) << 1)|WREG, 0x27, I2C_MEMADD_SIZE_8BIT, &aTxBuffer[4], 1, 10);//TADC_CONFIGWHILE HAL_I2C_Mem_Read(&hi2c1, ((0x20|0x02) << 1)|RREG, 0x24, I2C_MEMADD_SIZE_8BIT, &DATABuffer[0], 1, 10); HAL_I2C_Mem_Read(&hi2c1, ((0x20|0x02) << 1)|RREG, 0x25, I2C_MEMADD_SIZE_8BIT, &DATABuffer[1], 1, 10); HAL_I2C_Mem_Read(&hi2c1, ((0x20|0x02) << 1)|RREG, 0x26, I2C_MEMADD_SIZE_8BIT, &DATABuffer[2], 1, 10);
,
Kailyn Chen:
您好, 这两个波形都是读取寄存器的时序是吗? 如果是读的时序, 是不对的.
读时序: start- 7bit slave address(0x22)–read bit–ACK–register Address —ACK– repeat start– 7bit slave address—read bit–ACK—Register Data –stop.
在您给的时序里,不论是写时序还是读时序, 在从机地址0x22之后收到ACK,直接是寄存器的data,是不对的.
您参考下PGA305 的7.3.13.3 I2C Interface Protocol的介绍:
www.ti.com.cn/…/pga305.pdf
,
user4714975:
如PGA305 page31 I2C Read operation
S+SLAVE ADDR+W+ACK+REG ADDR+ACK+RS+SLAVE ADDR+R+ACK+DATA+STOP
第一次发的是write,第二次发的是读
我图上的data指的是REG DATA
,
user4714975:
每张图的第一次是Write,第二次是Read,Write后面的data是REG ADDR,Read后面的Data是读出的数据
,
Kailyn Chen:
好的,那时序没问题.
麻烦读下状态寄存器EEPROM_CRC_STATUS R, 看是否发生CRC error, TADC的值都为0 应该说明的是有CRC error.
配置寄存器0x5的bit0 EEPROM_CRC 配置为1之后,再去读TADC的值, 看下是否读取的还都是0 吗?