cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476: Interfacing with ADS7142

Ubus99
Associate III

Hi, I hope this is the right place to ask this.

I am trying to read data from a ADS7142 in manual mode dual channel-single ended.

Communication with the chip works just fine, but when the time comes to read the data, it only returns zeroes

Setup:

HAL_StatusTypeDef configure(I2C_HandleTypeDef *hi2c, uint8_t DeviceAddress) {
 
	do {
		HAL_StatusTypeDef buff = writeSingleRegister(hi2c, DeviceAddress,
				REG_CHANNEL_INPUT_CFG, 0b00); //dual single ended
		if (buff != HAL_OK) {
			return buff;
		}
	} while (readSingleRegister(hi2c, DeviceAddress, REG_CHANNEL_INPUT_CFG)
			!= 0b00);
 
	do {
		HAL_StatusTypeDef buff = writeSingleRegister(hi2c, DeviceAddress,
				REG_OPMODE_SEL, 0b100); //Manual auto sequence
		if (buff != HAL_OK) {
			return buff;
		}
	} while (readSingleRegister(hi2c, DeviceAddress, REG_OPMODE_SEL) != 0b100);
 
	do {
		HAL_StatusTypeDef buff = writeSingleRegister(hi2c, DeviceAddress,
				REG_AUTO_SEQ_CHEN, 0b11); //both channels
		if (buff != HAL_OK) {
			return buff;
		}
	} while (readSingleRegister(hi2c, DeviceAddress, REG_AUTO_SEQ_CHEN) != 0b11);
 
	calibrateOffset(hi2c, DeviceAddress);
	return HAL_OK;
 
}

Reading:

void Measure(I2C_HandleTypeDef *hi2c, uint8_t DeviceAddress,
		uint16_t *RxBuffer) {
	uint8_t intermediateBuffer[4];
	setBit(hi2c, DeviceAddress, REG_START_SEQUENCE, 0x1); //start sequencing
	HAL_I2C_Master_Receive(hi2c, DeviceAddress << 1, intermediateBuffer, 4,
			100);	//read data
	//HAL_I2C_Master_Seq_Receive_DMA(hi2c, DeviceAddress<<1, intermediateBuffer, 4, );
	setBit(hi2c, DeviceAddress, REG_ABORT_SEQUENCE, 0x1);	//stop sequencing
 
	RxBuffer[0] = intermediateBuffer[0] >> 4;
	RxBuffer[0] = intermediateBuffer[1] >> 12;
	RxBuffer[1] = intermediateBuffer[2] >> 4;
	RxBuffer[1] = intermediateBuffer[3] >> 12;
}

I'm not sure what is going on here, the manual provides no conversion delay, it only talks about continuous SCL, is this possible on STM32 at all?

I thought it might be with I2C_Master_seq_recieve, but I don't get the I2C_XferOptions.

1 ACCEPTED SOLUTION

Accepted Solutions
Ubus99
Associate III

Solved, typo in the binary OP-codes.

View solution in original post

1 REPLY 1
Ubus99
Associate III

Solved, typo in the binary OP-codes.