Hello, I'm attempting to use the SGTL5000 on a Teensy audio adapter board (https://www.pjrc.com/store/teensy3_audio.html) to output audio from a STM32H723GT6 MCU.
The problem I'm having is, the Lineout Output volume is really low (70mV peak-to-peak). No matter how I configure the registers, I cannot change the amplitude of the output, nor can I seem to mute it via modifying any registers (besides powering it down via CHIP_ANA_POWER).
I can verify I2C is working since writing to a register and reading it back returns the value I set the register to; And also reading a register before writing to it returns it's default values as expected. I can also verify I2S is working directly since writing 0xFFFF and 0x0000 interchangeably with a delay produces a square waveform on an oscilloscope. The SGTL5000 is running in slave mode.
I've directly translated the commands for setting up the IC from the source code used on the Teensy audio breakout board (https://github.com/PaulStoffregen/Audio), and I also referenced the code in the SGTL5000's datasheet. I checked VDDD (2.4v), VDDA (3.3v), and VDDIO (3.3v) and followed the I2C initialization commands for those values as outlined in the datasheet.
I am using relatively long wires for the I2S and I2C, but based on issues that come up doing this, it shouldn't effect my problem (https://forum.pjrc.com/index.php?threads/just-noise-with-teensy-3-6-and-audio-adaptor-board.41157/).
I've also checked the rate of my SYS_MCLK and it is 256*Fs as expected. The fall and rise time seem to be a bit higher than the datasheet says it seems to be, but that might be a result of my oscilloscope being inaccurate.
Here is my source code, note SGTL5000_writeI2S is simply a wrapper for HAL_I2S_Transmit in the hardware abstraction library for the STM32 processor:
void STGL5000_Init(I2C_HandleTypeDef *hi2c, I2S_HandleTypeDef *hi2s){
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_ANA_POWER_REG, 0x4060);
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_LINREG_CTRL_REG, 0x006C);
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_REF_CTRL_REG, 0x01F2);
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_LINE_OUT_CTRL_REG, 0x0F22);
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_SHORT_CTRL_REG, 0x4446);
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_ANA_CTRL_REG, 0x0071);
//Slave mode stuff
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_ANA_POWER_REG, 0x00AD);
// Power up Digital stuff
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_DIG_POWER_REG, 0x0021);
HAL_Delay(400);
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_LINE_OUT_VOL_REG, 0x001D); // set to 1.3 Vpp
// assuming slave
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_CLK_CTRL_REG, 0x0004);
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_I2S_CTRL_REG, 0x0030);
// routing
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_SSS_CTRL_REG, 0x0010);
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_ADCDAC_CTRL_REG, 0x0000); // disable DAC mute
//STGL5000_writeRegister(hi2c, SGTL5000_CHIP_ADCDAC_CTRL_REG, 0x000C); // disable DAC mute
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_DAC_VOL_REG, 0xFC3C); // digital gain, 0dB
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_ANA_HP_CTRL_REG, 0x7F7F); // set volume (lowest lv)
STGL5000_writeRegister(hi2c, SGTL5000_CHIP_ANA_CTRL_REG, 0x0077); // enable zero cross detectors
HAL_StatusTypeDef test = HAL_I2S_Init(hi2s);
int t = 0;
uint16_t val = 0;
while(1){
if (t)
STGL5000_writeI2S(hi2s, 0, 0xFFFF);
else
STGL5000_writeI2S(hi2s, 0, 0x0000);
t = !t;
//STGL5000_writeI2S(hi2s, 0, adcValue);
HAL_Delay(1);
}
}
