Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: sgtl5000 ADC lineInLevel() Gain Control

  1. #1

    sgtl5000 ADC lineInLevel() Gain Control

    FYI-Here is a very small item that caused me some confusion while using the sgtl5000 Audio Library routines. I did not find it mentioned anywhere in the forum so I thought I would document it for reference.

    The Audio Library method for adjusting the line in gains on the sgtl5000 ADCs is:

    bool AudioControlSGTL5000::lineInLevel(uint8_t left, uint8_t right)
    {
    if (left > 15) left = 15;
    if (right > 15) right = 15;
    return write(CHIP_ANA_ADC_CTRL, (left << 4) | right);
    }

    But the sgtl5000 data sheet details the CHIP_ANA_ADC_CTRL register as:

    Click image for larger version. 

Name:	ADC_CTRL_reg.jpg 
Views:	15 
Size:	136.3 KB 
ID:	23405

    So the method has the left/right reversed.

    As I said, very small issue, but it took me a bit to figure out why my code wasn't controlling the left/right ADC gains correctly.

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    7,983
    The question is, how to fix that.
    Fix the documentation only?
    +fix the names in the sourcecode, but with the current behaviour?

    Or fix the bug - that would mean to break old things.

  3. #3
    I don't think it is necessary to change any source code. It would be nice to include it in errata documentation somewhere if an errata exists.

    I just reversed things in my project code. I pointed it out so it might come up if someone having a similar problem searched the forum for help.

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    7,983

  5. #5
    Thanks for taking care of that. Good solution.

  6. #6
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    7,983
    No, thank YOU for posting it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •