Post Go back to editing

How to correctly convert GPIO input (23.5) to 28.0 number format?

Category: Software

Hi,

i'm a bit confused about how to use a GPIO-input with the Index Selectable Slewing Mux. The GPIO-Input outputs the values 0 and 1 in 23.5 Number format but the Mux awaits the values in 28.0 format.

To convert from 23.5 to 28.0 format I'd theoretically have to divide the GPIO-signal by 2^23 but this also doesn't work and leads to unexpected behavior of my whole program.

As a workaround I found out I could use the Min-block:

this outputs the minimum of both input values so constrains the result of the GPIO-block (which is a very big number from 28.0 format perspective) to 1, which works. But this seems like an odd solution for me. I'd rather do it the right way and also understand why the upper example isn't working as expected.



-
[edited by: the-powl at 10:01 AM (GMT -5) on 12 Nov 2022]
Parents
  •      Hello,

         Your use of the Min block is actually a clever solution, and has proven useful as part of more complex logic.  The standard way to adapt the (5.23) format GPIO to a (28.0) MUX input is the Buffer Gate.  When its own input is nonzero, it outputs a 1 in any format you select.  Set it to Bit 0 and that's all you need, as shown below:

         The format for audio signals (and GPIO inputs) for the ADAU1701 and similar is (5.23) -- defined as five bits before the binary point, and 23 bits after.  Its integer format has all 28 bits before the binary point.  If you're working with the ADAU1452 and higher DSPs, the audio and integer formats are (8.24) and (32.0) respectively.  As you have noted, audio format numbers are huge from an integer perspective -- although integer numbers have all their bits before their binary point, that binary point is shifted all the way to the right in the DSP's registers.  By definition,1.0 in audio (5.23 or 8.24) format is unity for multiply and divide; they leave any number unchanged.  Thus if you multiply an integer 1  by 1.0 in audio format, the result remains an integer 1.  We can use this result to convert audio numbers to integer:  simply multiply the audio format number by integer 1.  For the ADAU1701, multiply the (5.23) number by 1 in (28.0) format to get an integer (28.0) number for your MUX.

           To convert the -1701's audio format to integer format by division, we would need to divide by 2^23 -- a huge number that far exceeds the DSP's audio number range.  Also, since DSPs are multiply-and-add machines, most of them divide inefficiently.  In particular, the -1701's divide block uses many instructions. Thus, use multiplies rather than divides wherever possible.  Once again:  to convert an audio format number to integer, multiply it by 1 in integer format.

         Best regards,

         Bob

Reply
  •      Hello,

         Your use of the Min block is actually a clever solution, and has proven useful as part of more complex logic.  The standard way to adapt the (5.23) format GPIO to a (28.0) MUX input is the Buffer Gate.  When its own input is nonzero, it outputs a 1 in any format you select.  Set it to Bit 0 and that's all you need, as shown below:

         The format for audio signals (and GPIO inputs) for the ADAU1701 and similar is (5.23) -- defined as five bits before the binary point, and 23 bits after.  Its integer format has all 28 bits before the binary point.  If you're working with the ADAU1452 and higher DSPs, the audio and integer formats are (8.24) and (32.0) respectively.  As you have noted, audio format numbers are huge from an integer perspective -- although integer numbers have all their bits before their binary point, that binary point is shifted all the way to the right in the DSP's registers.  By definition,1.0 in audio (5.23 or 8.24) format is unity for multiply and divide; they leave any number unchanged.  Thus if you multiply an integer 1  by 1.0 in audio format, the result remains an integer 1.  We can use this result to convert audio numbers to integer:  simply multiply the audio format number by integer 1.  For the ADAU1701, multiply the (5.23) number by 1 in (28.0) format to get an integer (28.0) number for your MUX.

           To convert the -1701's audio format to integer format by division, we would need to divide by 2^23 -- a huge number that far exceeds the DSP's audio number range.  Also, since DSPs are multiply-and-add machines, most of them divide inefficiently.  In particular, the -1701's divide block uses many instructions. Thus, use multiplies rather than divides wherever possible.  Once again:  to convert an audio format number to integer, multiply it by 1 in integer format.

         Best regards,

         Bob

Children
No Data