Page 56 of the sgtl5000 datasheet has two formulas for calculating the attack and release rate. They both don't work for me.
Excel calcs are
#1 = (1-(10^(-(A9/(20*B9))))*2^19) and the result for (A9 or rate_dBs = 32) and (B9 or SYS_FS = 44.1) = -482267 or FFFFF8a425
#1 = (1-(10^(-(A9/(20*B9))))*2^19) and the result for (A9 or rate_dBs = 32) and (B9 or SYS_FS = 1) = -13168 or FFFFFFCC90
Raw formula says (1 - (10^(-(Rate_dBs/(20*SYS_FS)))) * 2^19
Anyway, this formula shouldn't be this complex. Just give the clock calculations and the math should be straitforward.
I have checked the formula, it is correct. The point is that the SYS_FS value in the formula should be specified in the units of Hz, not kHz. So, for example, for the sampling rate of 48kHz (48000Hz) and attack rate of 32dB/s the calculation is:
(1-(10^(-(32/(20*48000)))))*524288 = approx. 40.239 = approx. 40 = 0x28
that corresponds to the example value, given in the Data Sheet document.
Have a great day,
Artur
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Well, I suppose I should have tried adding the ')' where you did, but look at the datasheet again, the closing ')' is missing
Just throwing out some guesses
Its an overflow ticker, so
#1 = 0x10000 / Clock * dBsecond
#2 = 0x100000 / Clock * dBsecond
These come out in the ballpark anyway.