I'm developing a little program to control the TI DRV2605LEVM-MD evaluation module, similar to the TI Haptics Control Console, but specific for this board. It consists of a MSP430 microcontroller, a TCA9548A i2c switch and 8 DRV2605 haptic motor drivers connected to the switch.

While I'm actually able to make the motors run and play effects, I'm having quite a hard time figuring out how to read the driver's registers through the switch.

My actual poor idea of an i2c switch is basically an ic where you can activate or deactivate any channel/s to send i2c communications to the slaves, so my approach until now was:

A) Enable the needed channels

B) Configure those channels as outputs

C) Activate the desired channels

D) Send i2c query to the slave connected to the active channel.

This has been working so far with no problems, but now I need to read from that channel instead of write, and I've not been able to make it work with the same approach.

Reading the switch documentation, I've find the following register description:

Register 0: The Input Port register (register 0) reflects the incoming logic levels of the pins, regardless of whether the pin is defined as an input or an output by the Configuration register. It only acts on read operation. Writes to these registers have no effect. The default value, X, is determined by the externally applied logic level. Before a read operation, a write transmission is sent with the command byte to indicate to the I 2 C device that the Input Port register is accessed next.

Register 1: The Output Port register (register 1) shows the outgoing logic levels of the pins defined as outputs by the Configuration register. Bit values in this register have no effect on pins defined as inputs. In turn, reads from this register reflect the value that is in the flip-flop controlling the output selection, not the actual pin value.

Register 2: The Polarity Inversion register (register 2) allows polarity inversion of pins defined as inputs by the Configuration register. If a bit in this register is set (written with 1), the corresponding port pin polarity is inverted. If a bit in this register is cleared (written with a 0), the corresponding port pin original polarity is retained.

Register 3: The Configuration register (register 3) configures the directions of the I/O pins. If a bit in this register is set to 1, the corresponding port pin is enabled as an input with a high-impedance output driver. If a bit in this register is cleared to 0, the corresponding port pin is enabled as an output.

So, I think I understand at least what register 2 and 3 does: register 3 is used to tell the switch if you're going to use a channel as an output (write) or input (read), and register 2 reverses that behaviour. But for the first two registers, I have no clue.

I know I need to write to register 1 in order to enable that channel, then configure it as I/O writing to register 3 and finally raw-write to the switch to activate the channel, but this is for a writing operation. Raw-write is a concept that I do not understand, as this is my first experience with i2c and everything I've read so far involved register write.

Can anyone help out with this one?

  • \$\begingroup\$ -1 because of ambiguity: you didn't provide a circuit diagram, there is no link to the documentation for the eval board, a search of the TI website doesn't mention this particular board and the I/O expander you mentioned in the question does not allow you to do I2C. There is a link for a DRV2605LEVM-MD eval board, which uses a TCA9548A to multiplex 8 I2C slaves onto the master, which you do not mention in your question. Please clean up your question and the downvote will be inverted. \$\endgroup\$ – Adam Lawrence Mar 4 '16 at 17:20
  • \$\begingroup\$ Excuse me. You're totally right. I've been copying from the TI code and they sometimes use other notation. But the editor won't let me post more links (I need at least 10 reputation). The link to the board docs is this and the one to the switch this (this one is not updated yet in the question). \$\endgroup\$ – dvilela Mar 4 '16 at 17:29
  • \$\begingroup\$ This makes more sense. \$\endgroup\$ – Adam Lawrence Mar 4 '16 at 19:37

The polarity inversion register lets you do a logical NOT on any input line. It doesn't make an input into an output and vice versa.

Operation of this IC seems pretty straightforward:

  • Write to register 3 your specific input/output configuration
  • If you want the device to do a logical NOT (1->0, 0->1) on any of your input lines, set those bits in register 2
  • To read the input lines, read register 0
  • To write to the output lines, write to register 1
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.