I am having a bit of a hard time with an MCP3424 ADC. (datasheet)
Setup
The device is connected via I2C (100kB/s), the address is "1101000" (A1 and A2 tied to GND).
I can communicate with the device and write the configuration byte according to the timing diagram on page 21.
RESET
According to page 25 it is recommended to reset the device once via a general address call.
This looks like it is working since the device does send the ACK bit (9th bit held LOW):
PICTURE: Oscilloscope - General call RESET
Write config byte
After waiting >300us (power up again), I write the configuration byte which is also acknowledged:
Default config register byte (page 18):
RDY | C1 | C0 | O/C | S1 | S0 | G1 | G0 |
---|---|---|---|---|---|---|---|
0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
- RDY bit is not relevant (see conversion mode)
- Channel 0 is selected
- Conversion mode is continuous (-> setting RDY bit has no effect)
- Resolution is 12bit
- Gain = 1
Now for a test I want to read from Channel 2, so the configuration byte is: 01010000
PICTURE: Datasheet diagram vs Oscilloscope - Write config byte
Reading Data from device
According to the timing diagram on page 24, one has to read at least 3 bytes when a using 12 to 16 bit resolution. First and second byte (after the address byte) is the actual value, the third byte is the configuration register which is repeated as long as clock is provided and the master does not send NAK:
Problem
When I read 4 bytes:
- I do not get a valid raw voltage value (VDD on CH3)
- The device sends the default config byte as third byte.
- The device does not repeat the config byte on the forth byte.
PICTURE: Datasheet diagram vs Oscilloscope - Read 4 bytes
What I tried also
- I did try another MCP3424 IC to rule out the possibility of it beeing faulty.
- I looked at some Python libraries and found that people were using the smbus_i2c_read_block_data method. (apparingly because there was no method for just reading n-bytes without sending a command (or register) byte first).
I did also try that using
i2c_smbus_read_i2c_block_data()
method from "i2c-utils.h" with 0x00 as command code (also treid config byte).
But that only gives empty responses (still device send ACK bits.):
PICTURE: Oscilloscope - i2c_read_block_data
Your help is very much appreciated! Cheers, Roman