Tomas,
Thank you for the reply. It seems to be current related. I tried a 30-ohm speaker and the problem is nearly gone, I can turn it up all the way and it's still clear. An 8-ohm speaker is significantly better than the 4-ohm but I still can't turn it up more than about half volume before it starts distorting badly. With the 4-ohm speaker I can barely turn it up at all before it starts distorting, and the volume is much lower than what is possible with the 8 ohm speaker. It's as if the output current is very limited, but as best I can tell I've disabled the power limiting settings, maybe I missed something? When the sound is distorted, status register 0x15 bit 13 is set "1V8 analog regulator is off or output voltage level is too low", but the 1V8 power is not sagging so the error must be internal to the chip. This bit is not set at lower volumes when it is not distorting. I have tried multiple chips all with the same error. Bits 3 (LRCK1 too low) and 5 (SCK1 to LRCK1 ratio invalid) are also set, but I don't think this is related because the sound is very clear at low volumes.
To answer your questions:
(1) I copied my schematic below. I've tried many different register settings but this is how I'm setting it up at the moment:
tfa_write_reg(0x00, 0); //power down
tfa_write_reg(0x01, 0x08D8); // 0x08D8 = 10 0011 011 0 00 == 00 - I2S mode, 0 - No SCK polarity inversion, 011 - I2S data up to 24 bits, 0011 - 16kHz, 10 - left + right; sum of left and right....
nrf_delay_ms(10);
tfa_write_reg(0x00, 0x0001); //power up
tfa_write_reg(0x13, 0x1035); // Volume control, with 4-ohm speaker it distorts with any setting lower than 0x1055
tfa_write_reg(0x14, 0x0000); // Disable power limiting
tfa_write_reg(0x0F, 0x0008); // Clipping disabled, max power - bypass control table 27
tfa_write_reg(0x10, 0x92BA); // dynamic range compressor table 28
tfa_write_reg(0x00, 0x0009); //audio output enable
LRCK1 is running at 15873Hz (the closest to 16kHz possible with my processor) and SCK1 is 1523809Hz, giving almost exactly 96:1 ratio. LRCK2 and SCK2 are not connected.
(2) I'm using 258kB audio. 16 bit/sample, 16kHz sample rate, mono
(3) I'm not using any filters on the outputs
