I am having I2C issues communicating with an Analog Devices AD5112 Digital Pot.
The datasheet says it has a 16 Bit shift register so it seems you write 16 bits to it (2 bytes) and read back 2 bytes. The Commands are 4 Bits so with a 2 Byte command the Command could appear in any one of 4 places. The manual does not specify what nibble: Say I am using command 5 so with a two byte command I can have
- 50 00
- 05 00
- 00 50 and
- 00 05.
In the example below I use option 2. I am not attacking the chip, I cannot seem to get it working with the manual. Below is my overall main commands. The Interrupts and other overhead has been removed for clairity.
I2C1CONLbits.SEN = 1; // START
I2C1TRN = 0x5E; // POT CHIP WRITE ADDRESS SCOPE A
I2C1TRN = 0x05; // HI BYTE of Command, Command 5 is READ RDAC SCOPE B
// or the POT WIPER POSITION.
I2C1TRN = 0x00; // LO BYTE, This is just zero SCOPE C
// I want COMMAND 5
I2C1CONLbits.PEN = 1; // STOP This stop is GOOD Both Data SCOPE D
// & Clock are HI
I2C1CONLbits.SEN = 1; // START
I2C1TRN = 0x5F; // POT CHIP READ ADDRESS SCOPE E
I2C1CONLbits.RCEN = 1; // START to RECEIVE
I2C1CONLbits.ACKEN = 1; // ACK (We got 8 bits) SCOPE F
I2C_Hi_Byte = I2C1RCV; // SAVE VALUE
I2C1CONLbits.RCEN = 1; // START to RECEIVE
I2C1CONLbits.ACKEN = 1; // ACK (We got 8 bits) SCOPE G (TOOK OUT and it worked)
I2C_Lo_Byte = I2C1RCV ; // SAVE VALUE
I2C1CONLbits.PEN = 1; // STOP SCOPE H
After this MCU CLOCK is HI and it is ready and waiting, The POT CHIP is in Limbo. It is holding the data line low. The POT Chip must have issues with how I receive. I cannot get an interrupt at this point.
Entire I2C Scope Trace Zoomed in near start Zoomed in near end
I tried many combinations of command 5. It ried different combinations but I need better definition from the datasheet. What I am trying to do is get the RDAC value. Then, based on my voltage reading I adjust it either up or down, to get a VCC of 3.3V. When it is within 50mV of 3.3 VDC I want tp save the RDAC value to EEPROM, on the chip. The chip has all I need to do it. The datasheet tells of three byte and 4 byte command strings. Once that value is written to EEPRONM, every time it powers up the Value will be set.
The features of the chip intrigued me. I cannot get anything working with the chip at all (Except for acknowledgements) I know commands are getting to the Chip.