Post Go back to editing

ADAU1452 I2C Read Value and "do something"

Hello Slight smile

I'm actually a bit confused about the I2C Read in Sigma Studio (ADAU1452).

I2C Sequence write works perfectly to my external I2C device but I got no idea how to read a value from this device and how to "do something" with this value.
For example reading register 0x13 and if it's 0x01 then do this and if not do that.

I hope you know what I mean? It's actually not a technical problem, I simply got no idea how to implement this in sigma studio. Maybe you got a example for this?

Thanks for your help

Regards
Bernhard



.
[edited by: mantabernd at 8:06 AM (GMT -4) on 22 Mar 2022]
  • Hello Bernhard,

    Your question is actually difficult to answer because you left it open to "do something" with the I2C value. There is so much that can be done with the values and the exact thing to do will depend on what is required. What are the values? What do the values mean? What do you want to do with value X or Y?

    Under the Basic DSP in the tree toolbox, there is the Logic functions. Most of the time this is what you would use but at other times you might use a table to translate the input values to useful values in the DSP program. All depends on what is required. 

    Here is an example of a simple thing using a very handy ABCD block. I setup the I2C to have a default value of zero. Then I am imagining you are reading a register that has perhaps a PLL Locked signal, or Device good signal? So you would want to mute the output until the I2C value is not zero anymore. If it ever goes back to zero then mute it again. I used an externally controlled volume control with slew so it is a smooth transition. 

    This is just something I quickly whipped up with a project I already had on the screen. So tell us what you need to do and what possible values are likely to be read out of the target register?

    Dave T

  • Hello Dave,

    thanks for your quick reply.
    This actually helped me a lot and it's working now (except the readback... it still stays zero even if sigma studio gets the correct value from I2C bus).

    You can see this in the following example:

    I'm reading register 0x03 from my external audio amplifier (address 0xD5) and the result is 68 (0x44).
    ABCD comparation block works as expected but the readback block remains zero (doesn't matter where I put it and what data format I'm choosing).

    Actually not a big deal because I don't need the readback blocks in production, just annoying for debugging.

    Maybe you got a idea what I'm doing wrong.

    Regards 

    Bernhard

  • Hello Dave, 

    did you have time for checking this?
    It's really hard to troubleshoot the I2C bus if the readback doesn't work.

    Regards and thanks for your help
    Bernhard

  • Hello Bernhard,

    Can you send over your project? It will save me time replicating it. 

    It is difficult for me to set this up so having your project will help.

    Dave T

  • Hello Dave, 

    Sure but how can I send you my project file?

    Regards
    Bernhard

  • Hello Bernhard,

    You can either easily drag and drop your project file into the reply box or just follow these  steps of the attached picture.

    Regards,

    Harish

  • Wow ok this was too easy :D

    Attached my demo project file. I'm reading "68" from my I2C device through ADAU1452.
    My abcd block works as expected and unmutes the audio signal if read result is "68". If not it mutes the signal. So far so good Slight smile

    Unfortunately I'm not able to see this result in the Readback block. It would be very helpful for debugging porpuse if I would also see this I2C result without any need of a external I2C debugger.



    i2c_read_demo.dspproj

  • The customer ended up finding a problem with the USBi. It was writing data just fine but not reading back data correctly. Once he switched to a new USBi the readback worked properly.

    Dave T