Hi,
NCS1.9.1,nRF5340DK, VSCode,
see code, timer_lms==1000 spend 1000ms
but if start i2s
i2s_audio_init(); //this line will Slow down the time
timer_lms==200 spend 1000ms
nrfx_i2s_start will impact k_timer_start?

static int timer_lms=0;
void timer_ms_handler(struct k_timer *dummy)
{
if(timer_lms%1000==0)printk("ms:%d %d\n",timer_lms,timer_lms/1000);
timer_lms++;//k_work_submit(&my_work);
}
K_TIMER_DEFINE(my_timer, timer_ms_handler, NULL);
void main(void)
{
#if defined (NRF5340_XXAA_APPLICATION)
nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);//128MHz
#endif
k_timer_start(&my_timer, K_MSEC(1), K_MSEC(1));
i2s_audio_init();//this line will Slow down the time
while(true){k_msleep(1000);};
}

#define I2S_SCK_PIN 0x08
#define I2S_LRCK_PIN 0x23
#define I2S_SDOUT_PIN 0x09
#define I2S_SDIN_PIN 0x20
#define I2S_DATA_BLOCK_WORDS 40
static nrfx_i2s_buffers_t initial_buffers;
ISR_DIRECT_DECLARE(i2s_isr_handler)
{
nrfx_i2s_irq_handler();
ISR_DIRECT_PM(); /* PM done after servicing interrupt for best latency
*/
return 1; /* We should check if scheduling decision should be made */
}
static void data_handler(nrfx_i2s_buffers_t const *p_released, uint32_t status)
{
}
nrfx_err_t i2s_audio_init()
{
#if defined (NRF5340_XXAA_APPLICATION)
nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);//128MHz
IRQ_DIRECT_CONNECT(I2S0_IRQn, 0, i2s_isr_handler, 0);
#else
IRQ_DIRECT_CONNECT(I2S_IRQn, 0, i2s_isr_handler, 0);
#endif
//YOu should probably change this config to fit your I2S microphone and audio preferences.
nrfx_i2s_config_t config =NRFX_I2S_DEFAULT_CONFIG(I2S_SCK_PIN, I2S_LRCK_PIN,
NRFX_I2S_PIN_NOT_USED,I2S_SDOUT_PIN, I2S_SDIN_PIN);// NRFX_I2S_PIN_NOT_USED I2S_MCK_PIN
config.mode = NRF_I2S_MODE_MASTER;
config.ratio = NRF_I2S_RATIO_96X;
config.sample_width = NRF_I2S_SWIDTH_16BIT;
config.mck_setup = NRF_I2S_MCK_32MDIV42; //Preference freq = (MCKfreq/ratio) =8 KHz.
config.channels = NRF_I2S_CHANNELS_LEFT;
nrfx_err_t err_code = nrfx_i2s_init(&config, data_handler);
if (err_code != NRFX_SUCCESS)
{
printk("I2S init error\n");
return err_code;
}
err_code = nrfx_i2s_start(&initial_buffers, I2S_DATA_BLOCK_WORDS, 0); //start recording
if (err_code != NRFX_SUCCESS)
{
printk("I2S start error\n");
return err_code;
}
// nrfx_i2s_stop();
// k_sleep(K_SECONDS(2));
return err_code;
}
thanks
Best Regards