How Do I Implement I2C Master Register Read through LabVIEW?

Question from the Customer:

I am using the Aardvark I2C/SPI Host Adapter in I2C mode to perform a Master Register Read. Normally, I can do that with Aardvark Software API, but this time I’m using LabVIEW and it’s not working for me. How do I successfully implement I2C Master Register Read with LabVIEW?

Response from Technical Support:

Thanks for your question! The Master Register Write-Read, also known as Master Register Read, is actually a combination of two I2C transactions.

Master Register Write-Read

You can implement this transaction by calling two functions directly: aa_i2c_write() and aa_i2c_read().

  • The first API call is aa_i2c_write(). This call is used with the AA_I2C_NO_STOP flag, and contains the device register address from which to read.
  • The second API call is aa_i2c_read(), which sets the number of bytes to read.

Depending on the how the NO_STOP flag is set, this can be implemented as a single transaction or a pair of transactions.

Single Transaction

Here is an example of a full I2C transaction:

[Start] [Device Addr][W] [Register Addr] [Start] [Device Addr][R] [data] ... [data] [Stop]

Using the NO_STOP flag on the write effectively combines the two API calls into a single I2C transaction.

Two Transactions

The same operation can be achieved with two transactions.  The only difference is excluding the NO_STOP flag. Here is an example of using two I2C transactions for Master Register Write -Read:

[Start] [Device Addr][W] [Register Addr] [No-Stop]

[Start] [Device Addr][R] [data] ... [data] [Stop]

We have articles about using LabVIEW that may interest you, such as Create a Custom LabVIEW Application. This blog is about testing and evaluating SPI devices, but you can still refer to it as an example.

More information is available in our Knowledge Base, such as Sending I2C Messages Between Two Aardvark adapters Using Aardvark LabVIEW. This article is a good example for learning how to install the LabVIEW driver package, see the GUI interface, and send I2C data between two Aardvark adapters.

We hope this answers your questions. Additional resources that you may find helpful include the following:

If you want more information, feel free to contact us with your questions, or request a demo that applies to your application.

Request a Demo