Tool/software:
Hello,
I am going crazy when trying to read adc values from TLA2528.
The I2C single register read and write is fine. I set the FIX_PAT_ENABLE flag on register DATA_CFG.
In this case, reading 2 bytes, I get 0xA5A5 (not 0xA5A), is it correct?
I have set the capture in MANUAL MODE. The read of the STATUS REGISTER returns 0x80.
The code set the channel number from 0 to 7 and then read the ADC value.
When I remove the FIX_PAT_ENABLE flag, after the first reading of channel 0, the I2C level remains low so, when I try to write the Reg 0x11 to set next channel 1 I have an error on the I2C bus.
After reading the ADC value, has the Master to send a STOP?
This is the code I use to read the channel data:
uint16_t TLA2528_read_one_channel_data(uint8_t channel_num)
{
err_t ret;
uint16_t dataread = 0;
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (m_TLA2528_address << 1 ) | READ_BIT, ACK_CHECK_EN);
i2c_master_read(cmd, (uint8_t*)&dataread, 2, I2C_MASTER_ACK);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, 100 / portTICK_PERIOD_MS);
i2c_cmd_link_delete(cmd);
ERROR_CHECK(ret);
if (ret != OK ) LOGE(TAG, "TLA2528 I2C READ ERROR channel %d\n", channel_num);
return dataread;
}
What is wrong with my code?
Thank you