[00:06:49.411,024] <inf> i2s_nrfx: I2S MCK frequency: 256000, actual PCM rate: 8000
Hi,
Error code 11 is -EAGAIN, which simply means the I2S TX queue was full and i2s_write() timed out waiting for a free slot. This is expected if audio buffers are queued faster than the I2S hardware can transmit them. When this happens, one of the way could be to wait for some micro seconds and retry i2s_write().
Also note that as previously recommended increasing NUM_BLOCKS only adds more application buffers; it doesn’t change the driver’s internal TX queue size. To check that part, could you please share the relevant section of your prj.conf, especially any I2S or nrfx-related options?
Regarding MCK, you don’t need to generate it separately in code when I2S is set up as master.
Best Regards,
Syed Maysum
Hi Syed,
Thank you for the explanation.
Understood regarding error code 11 (-EAGAIN). I agree that this indicates the I2S TX queue is full and that the correct handling is to wait briefly and retry i2s_write() once the hardware has transmitted a buffer. I will add retry pacing on the application side and share the relevant I2S / nrfx-related options from prj.conf as requested.
Regarding MCK, I understand that when I2S is configured as master, the peripheral automatically generates and outputs MCK, so no separate software generation is required. My concern is mainly about the resulting MCK frequency and accuracy. From the I2S log, the internally generated MCK appears to be 256 kHz for an 8 kHz PCM rate (32× LRCK), whereas the codec datasheet recommends an MCK ratio of 256× LRCK (≈4 MHz for 16 kHz audio). I am currently verifying whether the internally generated MCK meets the codec’s clocking requirements when I2S is enabled.
I will follow up shortly with the prj.conf details and any additional observations.
Best regards,
Sharo
what changes i made my code to get proper transmission
Best Regards
Sharon
Hi,
Thanks for sharing the details and prj.conf. With retry pacing in place and CONFIG_I2S_NRFX_TX_BLOCK_COUNT=8, the earlier -EAGAIN TX queue behavior should now be handled correctly on the application side.
Regarding MCK: the nRF I2S peripheral does support generating MCK at 256x LRCK as shown here in master mode using the appropriate I2S ratio configuration. The current log shows 32x LRCK simply because of the current I2S clock configuration, not due to a hardware limitation.
The remaining question is whether your codec strictly requires 256x LRCK or just recommends it. If it is required, the next step would be to adjust the I2S configuration (ratio and MCK frequency) to generate MCK for the selected sample rate and verify that this frequency is achievable and within the codec’s tolerance.
Best Regards,
Syed Maysum
i2s require 4mhz
Thanks for sharing the details and prj.conf. With retry pacing in place and CONFIG_I2S_NRFX_TX_BLOCK_COUNT=8, the earlier -EAGAIN TX queue behavior should now be handled correctly on the application side.
i got same -eagen error
Hi,
On nRF54L15, the master clock (MCK) is generated by a frequency generator based on the MCKFREQ register and the sample rate (LRCK) is then derived as LRCK = MCK / RATIO.
Your log shows the I2S driver is currently selecting MCK=256 kHz with LRCK=8 kHz, which implies a 32x ratio. That is why the codec (which expects ~4 MHz MCK) does not match. If the codec requires ~4 MHz MCK, the I2S clocks should be configured for RATIO=512x so that at 8 kHz sample rate you get MCK = 8 kHz Ă— 512 = 4.096 MHz.
So if you want to get a higher MCK (~4 MHz), you should switch to using the nrfx_i2s driver directly. In nrfx_i2s, you can explicitly set:
Hopefully it should work. Best Regards,
Syed Maysum
One of another issue related to i2c communicatrion-
Initially the I2C communication works correctly, but after next debugg it starts failing with error -5 (I/O error) again another debugg it would be work correct again it will fail - I am confused with thi bug
Hi Sharon,
Thanks for your feedback. Just thinking if you are able to solve your request regarding higher MCK and it would be great if we could discuss issues one by one to avoid any confusion. So please correct me if I am wrong that according to your latest update there are 2 main issues. First you want to set the MCK to around 4 MHz and secondly you are getting -eagain error and error -5 errors both?
Could you please also share the output log around these errors (with logging enabled for the I2S driver), so we can see exactly where they occur?
Best Regards,
Syed Maysum