Can anyone give me tips on how to get the SCK to LRCK ratio of exactly 32?
I'm having a distorted audio problem with the TFA9879 amplifier, and the status register is reporting that my SCK to LRCK ratio is invalid (and that LRCK is too slow). My processor is the nrf52840 on the Rigado BMD-340 dev board (same as the PCA10056). My audio is 16-bit 16kHz mono (256 kB/sec) and the amplifier requires the SCK to LRCK ratio to be either 32 or 64. When I setup I2S as shown below, I believe I should be getting 1MHz on SCK and 31250Hz on LRCK. But with my scope I'm measuring 1MHz on SCK, and only 31.05kHz on LRCK. The end result is my amplifier is complaining that LRCK is too slow and the ratio of LRCK to SCK is invalid (register 15h bits 3 and 5) and the audio is horribly distorted. Is it actually possible to be off by this small amount? I suspect the error is in my measurement, but the status bits in the amplifier appear to agree with my measurements. Please help if you can!
nrf_drv_i2s_config_t config = {
.sck_pin = 31, \
.lrck_pin = 30, \
.mck_pin = 255, \
.sdout_pin = 29, \
.sdin_pin = 255, \
.irq_priority = 3, \
.mode = (nrf_i2s_mode_t)I2S_CONFIG_MODE_MODE_Master, \
.format = (nrf_i2s_format_t)I2S_CONFIG_FORMAT_FORMAT_I2S, \
.alignment = (nrf_i2s_align_t)I2S_CONFIG_ALIGN_ALIGN_Left, \
.sample_width = (nrf_i2s_swidth_t)I2S_CONFIG_SWIDTH_SWIDTH_16Bit, \
.channels = (nrf_i2s_channels_t)I2S_CONFIG_CHANNELS_CHANNELS_Left, \
.mck_setup = (nrf_i2s_mck_t)I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV4, \
.ratio = (nrf_i2s_ratio_t)I2S_CONFIG_RATIO_RATIO_256X,}; // See 14.4 I2S timing characteristics
SCK and LRCK: