This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TLV320AIC3254: Convert integer to coefficient data format

Part Number: TLV320AIC3254

I have a few volume controls in a miniDSP algorithm on a TLV320AIC3254 audio converter and want to control the volume levels from a host microcontroller over I2C. How do I convert a volume level in dB to a 24-bit volume coefficient? I recall seeing the conversion for this coefficient and others in the TI Audio Converters Wiki but I can no longer view the wiki page.

  • Hi, Rob,

     

    I am posting the content of the post you mention below.

    Converting from linear or dB values into hex values

    Applies to:

    • AIC3254-like devices (24-bit C-RAM)
    • AIC3111-like devices (16-bit C-RAM)
    • TASxxxx miniDSP devices (24-bit C-RAM)

    To convert from a dB or linear value into a format the device understands it is necessary to understand the data format of the device. The miniDSP devices store user-accessible variables in Coefficient Memory (C-RAM). The bit width of C-RAM may be different from device to device as shown above.

    As an example, the volume control volume level is determined by the value stored its C-RAM location. A 0dB volume level (1x gain) corresponds to 0x400000 (24-bit device) or 0x4000 (16-bit device). This means that the volume control assumes a 2.xx format, where the MSB is the sign bit, the MSB-1 is a magnitude bit and xx are the fractional bits. This is a 2's complement format, meaning that numbers will range [0x800000, 0x7FFFFF], where 0x80... is the most negative number and 0x7F...is the most positive number. Some examples:

    • 1.xx format: [-1, 0.999...], max 0 dB
    • 2.xx format: [-2, 1.999...], max 6dB
    • 3.xx format: [-4, 3.999...], max 12dB
    • 4.xx format: [-8, 7.999...], max 18dB

    In general, a number can be converted from decimal to a M.xx format hex value as follows:

    ValueHEX = DEC2HEX(ValueDEC x 2N-M), where N is the bit resolution of the memory location.

     If the value is provided in decibels (dB), it can be converted as follows:

    ValueHEX = DEC2HEX(10Value(dB)/20 x 2N-M)

    Note that values greater than 2N-1-1 and less than -2N-1 are out of bounds if converting to hex.

    As an example, for the volume control found in PurePath Studio (2.xx format), a gain of 0dB will result in:

    ValueHEX = DEC2HEX(100/20 x 224-2) = 0x400000

    The table below shows additional values.

      Example Volume Control Values in Hex

    To convert from hexadecimal back to decimal:

    ValueDEC = HEX2DEC(ValueHEX) / 2N-M

    To convert a decimal value back to dB:

    ValuedB = 20 x log10(ValueDEC)

    As an example, 0x400000 (as a 2.xx hexadecimal number) can be converted to linear as follows:

     ValueDEC = HEX2DEC(400000) / 224-2 = 1

    The dB / Linear to Hexadecimal calculator can be downloaded below:

    0523.dB_Linear_to_Hex.xlsx

    Best Regards,

      -Diego Meléndez López
       Audio Applications Engineer

  • Thanks for posting the content, Diego. Why was the wiki page closed? It contained lots of valuable information which isn't in the TLV320AIC32x4 documentation. If the wiki page is closed permanently, can you send an archive to me?