About nRF5340 Audio I2S SCLK settings

I want to edit the sample source (nRF5340 Audio) and program it on my own board.
The connection is CIS.
I am using NCS version 2.5.0.

I want to set the I2S clock as follows.
MCLK: 12.288MHz
BICLK: 3.072MHz
LRCK: 480kHz
Bit width: 32bit

What should I change and how?

  • Hi,

    nRF5340 product specification provides information about I2S peripheral in its chapter 7.15. In master mode, both serial clock (chapter 7.15.3) and left right clock (chapter 7.15.4) are generated from the master clock (MCK, chapter 7.15.5). MCK is generated from the clock source selected in the CONFIG.CLKCONFIG and CONFIG.MCKFREQ registers. The clock source for the master clock generator can be selected in the register CONFIG.CLKCONFIG. Depending on which clock source you use PCLK32M or ACLK, there are tables (chapter 7.15.5, Table 83 and 84) which provide configuration examples. Additionally, you can refer to nrfx I2S driver and its nrfx_i2s_config_t configuration structure. One example of using this structure can be found in this discussion.

    Best regards,
    Dejan

  • Thank you for your reply.

    I checked, but I don't quite understand.

    Please tell me specifically which parts of nRF5340 Audio I should change and how.

  • Hi,

    I would first recommend that you update to the NCS v2.6.1. 

    For setting the clock and bit width to the ones supported by the application, please refer to the nrf\applications\nrf5340_audio\src\audio\Kconfig and specifically to AUDIO_SAMPLE_RATE_HZ and AUDIO_BIT_DEPTH. This would result in correct I2S settings without further actions from your side. However, if you have requirements that does not fall within supported settings, you can look at the nrf\applications\nrf5340_audio\src\modules\audio_i2s.c file. This file contains configuration for I2S. There you can find MCLK configuration. Currently, clock supports only 16 KHz, 24 KHz and 48 KHz sampling rates. By selecting the ratio located in the Kconfig file in combination with sample width from the same Kconfig file, LRCK and BCLK can be obtained. If you want to have a different ratio then you can refer to CS47L63 TRM in nrf\application\nrf5340_audio\src\drivers\cs47l63_reg_conf.h and modules\hal\nordic\nrfx\hal\nrfx_i2s.h for register settings. New sample ratio would need to be defined in nrf\applications\nrf5340_audio\src\modules\audio_i2s.c and the Kconfig mentioned above should be updated to allow that frequency to be selected.

    Best regards,
    Dejan

     

  • Thank you for your reply.

    The current setting of 48kHz for LRCK is fine, so to change the bit width to 32bit I added the following to the prj_release.conf file:

    CONFIG_AUDIO_BIT_DEPTH_32=y

    I was also able to check the waveform with an oscilloscope.

    I still don't know how to change MCLK.

    Which part of which file should I change, and how?

    Please tell me specifically.

Related