Part Number: ADS7142
Goodmorning, I'm facing a problem with the analogue data conversion using the ADS7142IRUGR component.
According to the Datasheet I would like to use the Manual Mode, with AUTO Sequencing enabled to convert both channels. But, although I followed the flowchart, I only get the value of channel Ch0, since the result of a 4 byte reading, as per figure 56 of the data-sheet, returns the same result on byte[0] - byte[1], compared to byte[2]-byte[3].
I've tested the single commands on I2C and they works fine (the microcontroller get the ACK).
I report my example code, in order to easily identify the error.
Thank you in advance,
Luca
[EXAMPLE CODE]
/*-----------------------------------------------------------------------------
* VMEAS: External ADC
*-----------------------------------------------------------------------------*/
#define ADS7142_I2C_ADDR 0x1B // ADS7142 I2 Address
/*-----------------------------------------------------------------------------
* ADS7142: Register MAP
*-----------------------------------------------------------------------------*/
#define ADS7142_OPMODE_I2CM_STATUS 0x00 // Provides the present Operating Mode and I2C mode information
#define ADS7142_DATA_BUFFER_STATUS 0x01 // Provides the present status of Data Buffer 00ACCUMULATOR CONTROL REGISTERS
#define ADS7142_ACCUMULATOR_STATUS 0x02 // Provides the present status of Accumulator DIGITAL WINDOW COMPARATOR REGISTERS
#define ADS7142_ALERT_TRIG_CHID 0x03 // Provides the channel ID of channel which was first to set the alert output
#define ADS7142_SEQUENCE_STATUS 0x04 // Provides the status of sequence in device OSCILLATOR and TIMING CONTROL REGISTERS
#define ADS7142_ACC_CH0_LSB 0x08 // Provides the LSB of accumulated data for CH0 (Read Only)
#define ADS7142_ACC_CH0_MSB 0x09 // Provides the MSB of accumulated data for CH0 (Read Only)
#define ADS7142_ACC_CH1_LSB 0x0A // Provides the LSB of accumulated data for CH1 (Read Only)
#define ADS7142_ACC_CH1_MSB 0x0B // Provides the MSB of accumulated data for CH1 (Read Only)
#define ADS7142_ALERT_LOW_FLAGS 0x0C // Latched flags for Low alert
#define ADS7142_ALERT_HIGH_FLAGS 0x0E // Latched flags for High alert
#define ADS7142_DEVICE_RESET 0x14 // Reset device
#define ADS7142_OFFSET_CAL 0x15 // Initiate the internal Offset calibration cycle
#define ADS7142_OPMODE_SEL 0x1C // Sets the operation mode and enables auto-sequencing
#define ADS7142_WKEY 0x17 // Write KEY Register
#define ADS7142_OSC_SEL 0x18 // Selects the oscillator for the conversion process
#define ADS7142_nCLK_SEL 0x19 // Sets the nCLK for the device DATA BUFFER CONTROL REGISTER
#define ADS7142_START_SEQUENCE 0x1E // Starts the channel scanning sequence
#define ADS7142_ABORT_SEQUENCE 0x1f // Aborts the channel scanning sequence
#define ADS7142_AUTO_SEQ_CHEN 0x20 // Enables Auto sequencing for selected channels
#define ADS7142_CHANNEL_INPUT_CFG 0x24 // Configures the analog input channels ANALOG MUX and SEQUENCER REGISTERS
#define ADS7142_DOUT_FORMAT_CFG 0x28 // Configures the data output format for data buffer
#define ADS7142_DATA_BUFFER_OPMODE 0x2C // Selects Data Buffer operation mode
#define ADS7142_ACC_EN 0x30 // Enables the Accumulator
#define ADS7142_ALERT_CHEN 0x34 // Enables Alert functionality for individual channels
#define ADS7142_PREALT_MAX_EVNT_CNT 0x36 // Sets the Pre-Alert Event Counter for both channels
#define ADS7142_ALERT_DWC_EN 0x37 // Enables the Alert and Digital Window Comparator block
#define ADS7142_DWC_HTH_CH0_LSB 0x38 // Sets the LSB for High Threshold for CH0
#define ADS7142_DWC_HTH_CH0_MSB 0x39 // Sets the MSB for High threshold for CH0
#define ADS7142_DWC_LTH_CH0_LSB 0x3A // Sets the LSB for Low threshold for CH0
#define ADS7142_DWC_LTH_CH0_MSB 0x3B // Sets the MSB for Low threshold for CH0
#define ADS7142_DWC_HTH_CH1_LSB 0x3C // Sets the LSB for High threshold for CH1
#define ADS7142_DWC_HTH_CH1_MSB 0x3D // Sets the MSB for High threshold for CH1
#define ADS7142_DWC_LTH_CH1_LSB 0x3E // Sets the LSB for Low threshold for CH1
#define ADS7142_DWC_LTH_CH1_MSB 0x3F // Sets the MSB for Low threshold for CH1
#define ADS7142_DWC_HYS_CH0 0x40 // Sets Hysteresis for CH0
#define ADS7142_DWC_HYS_CH1 0x41 // Sets Hysteresis for CH1
/*-----------------------------------------------------------------------------
* ADS7142: Code
*-----------------------------------------------------------------------------*/
{
uint16_t adcRes1, adcRes2;
uint8_t adcCh1, adcCh2;
[...]
// 1 - Configure ADC Operating Mode
txBuffer[0] = ADS7142_OPMODE_SEL;
txBuffer[1] = 0x04; // Auto Seq
// Send to I2C
i2C_res = i2c_send_and_receive(&i2c_tx_params_vmeas);
HAL_Delay(50);
// 2 - Configure for sequence ADC Channel CH0+CH1
txBuffer[0] = ADS7142_AUTO_SEQ_CHEN;
txBuffer[1] = 0x03;
// Send to I2C
i2C_res = i2c_send_and_receive(&i2c_tx_params_vmeas);
HAL_Delay(50);
// 3 - Start ADC Sequence
txBuffer[0] = ADS7142_START_SEQUENCE;
txBuffer[1] = 0x01;
// Send to I2C
i2C_res = i2c_send_and_receive(&i2c_tx_params_vmeas);
HAL_Delay(5);
// 4 - Read result on the device
HAL_I2C_Master_Receive(&hi2c1, (ADS7142_I2C_ADDR<<1), rxBuffer, 4, 50);
adcRes1 = ((uint16_t)rxBuffer[0]<<4) + ((rxBuffer[1]&0xF0)>>4);
adcRes2 = ((uint16_t)rxBuffer[2]<<4) + ((rxBuffer[3]&0xF0)>>4);
adcCh1 = rxBuffer[1] & 0x0F;
adcCh2 = rxBuffer[3] & 0x0F;
[...]
}