Jump to content
  • 0

AD2 I2C via C++


primesc

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! 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

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.

Link to comment
Share on other sites

@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! 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...