• 0
Sign in to follow this  
primesc

AD2 I2C via C++

Question

Hi, I've created a custom software program in C++ that uses analog discovery 2 and I have two questions.

1. I want to read some data using I2C interface, but I'm having trouble on the idea of how should I set up a "typical I2C" interface in C++. Is there an example anywhere on how exactly can this be accomplished in C++?

2. When reading the on-board temperature value in C++ I keep receiving a constant value if I'm doing multiple reads in a row. How can I fix it so that every time I read the AD2 on-board temp value I would get an updated temp value not the initial value? 

Thank you! 

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi @primesc

1. The WaveForms application/Protocol tool uses the Digital In/Out functions to implement UART, SPI, I2C.
At the moment there is no WF SDK example for I2C.

2. You might be reading "constant" value because the temperature is changing slowly.
As noted in the AnalogIO_AnalogDiscovery2_SystemMonitor.py example, use the FDwfAnalogIOStatus to fetch readings from device. The FDwfAnalogIOChannelNodeStatus returns value obtained by the last AIOStatus call.

Share this post


Link to post
Share on other sites
  • 0

@attila

Thank you for the quick response! So, it is possible to do it in C++ using the same methodology as WaveForms application uses? 

If so, would you be able to give me a small idea on how exactly or some pointers? I assume that I should create a clock at 100k with 50% duty cycle for SCLK, but my main questions comes in how do I generate the SDA line? 

I would be more than happy to post my I2C module here or send it to you guys after I've finished so that other people can use it as well. :)

Thank you once again and Happy Thanksgiving! 

Edited by primesc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this