# ADAU1450 volume setting from microcontroller

Question asked by Reini on Feb 3, 2018
Latest reply on Feb 3, 2018 by KJBob

Hello all,

I could use your help with the following:

We have an Adau1450 connected with I2C to a microcontroller. In the 1450 is a volume controller which I have to set with 8.24 fixedpoint values. But I don't want to do complex computations in my microcontroller, that's what the DSP can do much better :-)

So, I was thinking, can I calculate the right volume setting in the DSP if I feed it with integer values in the range of, say, -9600 to +600 (which represent a volume range of -96.00dB to +6.00dB) ? In the DSP there should be some calculation, which converts the integer dB values to a fixedpoint value for a Single Volume component. Or is it possible to write the calculated value directly to the I2C address of an other volume slider?

The fixedpoint values have a range of about -128.00 to +128.00 Where can I find how the DSP converts integer to fixedpoint values? I now use a lookup table in the microcontroller with fixedpoint values for volumes in range of -96dB to +6dB in steps of 0.5dB. But then I thought, why not feeding the requested value in dB's to the DSP, and let him/her do the math? I really want to get rid of the lookuptable and want to be able to set the volume more accurate then in steps of 0.5dB

For the lookuptable I wrote a small Delphi program which creates a table. To convert a dB value to fixedpoint 8.24 I use the following code:

`One_dB := 0.11512925464970228420089957273422;Volume := -96.0; // one entry, others are -95.5, -95.0, -94.5, -94.0, .. etc.VolFixedPoint := Exp(Volume*One_dB);RegisterValue := Round(VolFixedPoint*\$01000000); // ADAU1450`

RegisterValue is the value what is added to the table.

This calculation should be done in the DSP if that is possible of course :-)

Hope someone has a hint :-)

With kind regards,

Reini