Other Parts Discussed in Thread: ADS1220
The software sends commands 0X23 read registers, and the data is received all the 0XFF. It was supposed to receive the three data of 05, 42, 80, but received it was 0XFF high. What is the reason for this?
static int Dev_ads1120_Config(void) { struct ADS1120_REGS regs; memset(®s, 0, sizeof(regs)); /* 系统复位 */ Dev_ads1120_Reset(); regs.R0.PGA_BYPASS = 0x0; //0: PGA enabled (fault) 1: PGA disenabled and bypassed regs.R0.GAIN = 0x0; //0: Gain = 1 (default) regs.R0.MUX = 0x0; //0: AINP = AIN0, AINN = AIN1 (default) regs.R1.DR = 0x0; //0: 20 SPS regs.R1.MODE = 0x0; //0: Normal Mode (256kHz default) regs.R1.CM = 0x1; //0: Signal-shot mode (default) 1: Continuous conversion mode regs.R1.TS = 0x0; //0: Disable temperature sensor 1: Enable temperature sensor regs.R1.BCS = 0x1; //0: Current sources off (derfault) 1: Current sources open regs.R2.VREF = 0x1; //1: External reference selected using dedicated REFP0 and REFN0 inputs regs.R2.RES_5060 = 0x0; regs.R2.PSW = 0x0; regs.R2.IDAC = 2; //0: OFF(default) regs.R3.I1MUX = 0X4; //0: IDAC1 disabled (default) regs.R3.I2MUX = 0x0; //0: IDAC2 disabled (default) regs.R3.DRDYM = 0x0; regs.R3.RES_0 = 0x0; Dev_ads1120_WriteReg(ADDR_REG_0, (uint8_t *)®s, 4); memset(®s, 0, sizeof(regs)); Dev_ads1120_ReadReg(ADDR_REG_0, (uint8_t *)®s, 4); return 0; } static int Dev_ads1120_WriteReg(uint8_t addr, uint8_t *buf, uint8_t lens) { uint8_t cmd[5] = {0}; cmd[0] = CMD_WREG | (addr << 2) | (lens - 1); memcpy(cmd + 1, buf, lens); Spi_SetCS(M0P_SPI0, FALSE); Spi_SendBuf(M0P_SPI0, cmd, lens + 1); delay1us(1); Spi_SetCS(M0P_SPI0, TRUE); return 0; } static int Dev_ads1120_ReadReg(uint8_t addr, uint8_t *buf, uint8_t lens) { uint8_t cmd[4] = {0}; cmd[0] = CMD_RREG | (addr << 2) | (lens - 1); Spi_SetCS(M0P_SPI0, FALSE); Spi_SendData(M0P_SPI0, cmd[0]); Spi_ReceiveBuf(M0P_SPI0, buf, lens); delay1us(1); Spi_SetCS(M0P_SPI0, TRUE); return 0; } static int Dev_ads1120_Reset(void) { uint8_t cmd[2] = {CMD_RESET}; Spi_SetCS(M0P_SPI0, FALSE); Spi_SendBuf(M0P_SPI0, cmd, 1); Spi_SetCS(M0P_SPI0, TRUE); delay1us(100); return 0; }