Well-known member
I would like to have tips for configuring the audio card CODEC. I configured a LINE input (left channel) and an I2S_DOUT output and I get the following signals.


Here my code :
void SGTL5000_init(void){

    write(CHIP_ANA_POWER_ADD, 0x0432);                  // VDDD is externally driven with 1.8V+ SGTL5000 Silicon Errata. PLL = read(CHIP_ANA_POWER_ADD);      // Check
    write(CHIP_LINREG_CTRL_ADD, 0x006C);                  // VDDA & VDDIO both over 3.1V
    write(CHIP_REF_CTRL_ADD, 0x01FE);                     // VAG=1.575, normal ramp, -50% bias current
    write(CHIP_LINE_OUT_CTRL_ADD, 0x0000);                 // Not used
    write(CHIP_SHORT_CTRL_ADD, 0x0000);                  // Not used

    //---------------- Route LINEIN\ADC\I2S_OUT---------------------
    write(CHIP_ANA_CTRL_ADD, 0x046);                      // enable zero cross detectors, LINEIN input, HP
    write(CHIP_ANA_HP_CTRL_ADD, 0x0000);                 // +12dB = LEFT and RIGHT
    // write(CHIP_SSS_CTRL_ADD, 0x0000);                // ADC to I2S_OUT

    write(CHIP_DIG_POWER_ADD, 0x0073);                     // power up ADC and I2S_OUT and all digital stuff

    write(CHIP_LINE_OUT_VOL_ADD, 0x1D1D);                 // Not used
    write(CHIP_CLK_CTRL_ADD, 0x0004);                      // 256*Fs, 44.1 kHz
    write(CHIP_I2S_CTRL_ADD, 0x0030);                     // Slave Mode, 16bit, I2S format

    //---------------- PLL Configuration ---------------------
    write(CHIP_CLK_TOP_CTRL_ADD, 0x0000);
    write(CHIP_PLL_CTRL_ADD, 0x101C);

    //---------------- Input Volume Control---------------------
    // Configure ADC left and right analog volume to desired default.
    // Example shows volume of 0dB
    write(CHIP_ANA_ADC_CTRL_ADD, 0x0000);   
I tried to store 128 values in an array but I get random values, could you tell me if my code is correct to configure the CODEC? Thank you for your help.
Normally the audio library is used with the audio board. The best way to get started and learn the audio library is with this 31 page tutorial.

If you scroll down on that page, you can also find a 45 minute video which demonstrates all steps of the tutorial. If you get stuck or just prefer to watch rather than read, hopefully the video can help.

The audio library is open source. If you really want to dive into the low-level code, you can. But you should at least use the library to get working sound first. Creating all the low-level code from scratch is a steep uphill climb. Best to start with a known-good system and then dive into the low-level details when it is fully working.
Teensy 4.0 and Teensy 4.1 work with audio shield rev D.

For the Teensy 4.0 how should I do the wiring with the audio card ? Do you have an existing diagram ? Do I need other things to communicate with the Audio card ?
I have this picture :

I think it connects directly to the top of the audio card, right ? Does it have USB cables, connectors or microphone to have a complete system ?
It seems to me that the Rev.D audio card is more suitable for the TEENSY 4.0 card


I have 28 pins on the audio card and 24 pins also on the Teensy 4.0 card
Thank you
Last edited:
You may want to have close look at this page where all the information about the audio adapter is available [schematic, wiring, mounting, reference to the Audio library, etc].
The audio adapter can be used for both the Teensy 4.0 and the Teensy 4.1.