Jump to content
  • 0

I2C and static digital IO on AD3


EVC

Question

I am developing a PCB of a test setup based on AD3.

I am using I2C to control a couple of I2C I/O expanders to control relays (lots of them).

There are a few other devices (relays, LEDs, switches etc.) that I was thinking of controlling through the digital I/O signals. I found a recent thread with a similar use case. That user, though, was trying to use the DigitalOut functions and I understood it is not possible using both, protocol and Digital[In/Out] because of resource conflicts.

I only need static I/O and, one of the answers by @attila suggests that it should be possible using DigitalIO:

Quote

You can use the digital-io functions to control the DIOs.

 

I implemented two small classes in python to perform the i2c and DigitalIO functions I need, and I have run a few tests. In a very similar way as user @liu, I can have the object instances of either class to work separetely, but when I create the i2c object and then the DigitalIO object, this latter breaks the former (it returns "NAK -1").

 

Looking at the pdf version of the reference manual, I found this:

Quote

The digital IO signals are shared in the device between Digital-IO, Out and In functions. The Digital-IO has priority over Digital-Out. The Digital-Out is only applied for a signal when the Digital-IO Enable and Output are zero for the respective bit.
 

 

I obviously made some mistake as the statement above is not entirely clear to me. Is there an example or code snippet that I could use as a basis to allow me to use both I2C and DigitalIO without conflicts?

 

Thanks in advance.

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 1

Hi @EVC

You can use freely use the FDwfDigitalIO functions to control DIOs, just make sure not to override the SCL/SDA DIOs used by the FDwfDigitalI2c or FDwfDigitalOut functions. So, if SCL/SDA is DIO 0/1 then for digitalio function make sure the output enable and value with do not control 0x0003, like mask it with 0xFFFC, DIO 15:2

 

Link to comment
Share on other sites

  • 0
17 hours ago, attila said:

So, if SCL/SDA is DIO 0/1 then for digitalio function make sure the output enable and value with do not control 0x0003, like mask it with 0xFFFC, DIO 15:2

 

Hello @attila, first off, thank you for your prompt response. It turns out I was writing ones to the I2C DIOs as I assumed only the bits set by FDwfDigitalIOOutputEnableSet would be altered.

Thank you very much for your great support.

Link to comment
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
×
×
  • Create New...