I'm working with the ADS7142 device using a nordic Platform with I2C.
this is my configuration:
header file using ADS7142RegisterMap.h in sbac201a。
IIC frequency is 400K
static uint8_t const offset_cal[] = {SINGLE_REG_WRITE, ADS7142_REG_OFFSET_CAL, ADS7142_VAL_TRIG_OFFCAL};
static uint8_t const channel_input_cfg[3] = {SINGLE_REG_WRITE, ADS7142_REG_CHANNEL_INPUT_CFG, ADS7142_VAL_CHANNEL_INPUT_CFG_1_CHANNEL_PSEUDO_DIFF};
static uint8_t const operation_mode_sel[] = {SINGLE_REG_WRITE, ADS7142_REG_OPMODE_SEL, ADS7142_VAL_OPMODE_SEL_I2C_CMD_MODE_W_AUTO_SEQ_EN};
static uint8_t const auto_seq_channel_cfg[] = {SINGLE_REG_WRITE, ADS7142_REG_AUTO_SEQ_CHEN, ADS7142_VAL_AUTO_SEQ_CHENAUTO_SEQ_CH0};
static uint8_t const start_conversion_cfg[] = {SINGLE_REG_WRITE, ADS7142_REG_START_SEQUENCE, ADS7142_VAL_START_SEQUENCE}; //start
static uint8_t const abort_conversion_cfg[] = {SINGLE_REG_WRITE, ADS7142_REG_ABORT_SEQUENCE, ADS7142_VAL_ABORT_SEQUENCE}; //abort
/****************************************************************************/
app_twi_transfer_t const ads7142_init_param[] = {
APP_TWI_WRITE(ADS7142_SLAVE_ADDR, abort_conversion_cfg, sizeof(abort_conversion_cfg), 0),
APP_TWI_WRITE(ADS7142_SLAVE_ADDR, offset_cal, sizeof(offset_cal), 0),
APP_TWI_WRITE(ADS7142_SLAVE_ADDR, channel_input_cfg, sizeof(channel_input_cfg), 0),
APP_TWI_WRITE(ADS7142_SLAVE_ADDR, operation_mode_sel, sizeof(operation_mode_sel), 0),
APP_TWI_WRITE(ADS7142_SLAVE_ADDR, auto_seq_channel_cfg, sizeof(auto_seq_channel_cfg), 0),
APP_TWI_WRITE(ADS7142_SLAVE_ADDR, start_conversion_cfg, sizeof(start_conversion_cfg), 0),
};
nrf_drv_gpiote_in_config_t ads_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
nrf_drv_gpiote_in_init(ADS7142_BUSY_PIN, &ads_config, mg_adc_read_handler); ///And BUSY/RDY PIN , Falling edge trigger interrupt.
mg_gpiote_enable()
static void read_ads7142_cb_handler(ret_code_t result, void* p_user_data) {
NRF_LOG_INFO("aaaaaaaaa\n");
for(;i < 4;i++){
NRF_LOG_INFO("adc: %#x\n", m_adc_buffer[i]);
}
}
void ads7142_data_read(void) {
static app_twi_transfer_t const transfers[] = {
ADS7142_READ(ADS7142_SLAVE_ADDR, m_adc_buffer, 4),
};
static app_twi_transaction_t const transaction = {
.callback = read_ads7142_cb_handler,
.p_user_data = NULL,
.p_transfers = transfers,
.number_of_transfers = sizeof(transfers) / sizeof(transfers[0])};
APP_ERROR_CHECK(app_twi_schedule(&m_twi_ads7142, &transaction));
}
I can read register value correctly.
After this configuration, read ADS7142_SLAVE_ADDR 4 bytes.
no matter I start_conversion_cfg or abort_conversion_cfg, my interrupt is not triggered.
manual call ads7142_data_read() read conversion funtion four times, get result followed.
:INFO:busy pin:0:INFO:aaaaaaaaa
:INFO:adc: 0xe0
:INFO:adc: 0x40
:INFO:adc: 0xff
:INFO:adc: 0x10
:INFO:busy pin:0:INFO:aaaaaaaaa
:INFO:adc: 0xee
:INFO:adc: 0x40
:INFO:adc: 0xeb
:INFO:adc: 0xe0
:INFO:busy pin:0:INFO:aaaaaaaaa
:INFO:adc: 0xf8
:INFO:adc: 0
:INFO:adc: 0xf6
:INFO:adc: 0xe0
:INFO:busy pin:0:INFO:aaaaaaaaa
:INFO:adc: 0xf7
:INFO:adc: 0x70
:INFO:adc: 0xff
:INFO:adc: 0x50
The received values are changing all the time and this value is too large.