Clock configuration

Hi,I have been using I2S communication in nrf54l15 DK board with zephyr but couldn't able to get clock to I2s .I couldn't able to get configure clock in overlay file ,can you help me with that.

i2s_rxtx:&i2s20 {
	status = "okay";
	pinctrl-0 = <&i2s20_default>;
	pinctrl-names = "default";
	
};

&pinctrl {
	i2s20_default: i2s20_default {
		group1 {
			psels = <NRF_PSEL(I2S_SCK_M, 0, 2)>,
					<NRF_PSEL(I2S_LRCK_M, 0, 3)>,
					<NRF_PSEL(I2S_SDOUT, 1, 0)>,
					<NRF_PSEL(I2S_SDIN, 1, 1)>;

		};
	};
};
// &clock {
// 	zephyr,deferred-init;
// };

Parents
  • Hello,

    Make sure to fulfill the requirement set here:
    https://docs.nordicsemi.com/bundle/ps_nrf54L15/page/chapters/pin.html#ariaid-title3 

    In specific that both MCK and SCK need to use a pin that is a "Clock pin", see Table 3. QFN48 pin assignments for which pins are "Clock pin".

    Kenneth

  • In that specified I need to use only clock pin only for MCK,SCK right? . I have gone through pin assignment and changed SCK to p1.03  even though I am not able to get data.Do I need to configure and clock setup in overlay?

    #include <zephyr/kernel.h>
    #include <zephyr/sys/printk.h>
    #include <zephyr/drivers/i2s.h>
    #include <zephyr/drivers/gpio.h>
    #include <string.h>
    
    #define I2S_RX_NODE DT_NODELABEL(i2s_rxtx)
    
    #define SAMPLE_FREQUENCY 16000
    #define SAMPLE_BIT_WIDTH 32
    #define BYTES_PER_SAMPLE sizeof(int16_t)
    #define NUMBER_OF_CHANNELS 1
    #define SAMPLES_PER_BLOCK ((SAMPLE_FREQUENCY / 10) * NUMBER_OF_CHANNELS)
    #define INITIAL_BLOCKS 2
    #define TIMEOUT 1000
    
    #define BLOCK_SIZE (BYTES_PER_SAMPLE * SAMPLES_PER_BLOCK)
    #define BLOCK_COUNT (INITIAL_BLOCKS + 2)
    K_MEM_SLAB_DEFINE_STATIC(mem_slab, BLOCK_SIZE, BLOCK_COUNT, 4);
    
    static int16_t echo_block[SAMPLES_PER_BLOCK];
    uint8_t loopCnt = 0;
    
    static void process_block_data(void *mem_block, uint32_t number_of_samples)
    {
    	for (int i = 0; i < number_of_samples; ++i)
    	{
    		int16_t *sample = &((int16_t *)mem_block)[i];
    		// *sample += echo_block[i];
    		// echo_block[i] = (*sample) / 2;
    		echo_block[i] = *sample;
    		// printk("%d\n", echo_block[i]);
    	}
    	printk("Samples: %d\n", number_of_samples);
    	// k_sleep(K_MSEC(100));
    }
    
    static bool configure_streams(const struct device *i2s_dev_rx, const struct i2s_config *config)
    {
    	int ret = i2s_configure(i2s_dev_rx, I2S_DIR_RX, config);
    	if (ret == 0)
    	{
    		printk("Configure Stream Successful.\n");
    		return true;
    	}
    	printk("Failed to configure streams: %d\n", ret);
    	return false;
    }
    
    static bool trigger_command(const struct device *i2s_dev_rx, enum i2s_trigger_cmd cmd)
    {
    	int ret = i2s_trigger(i2s_dev_rx, I2S_DIR_RX, cmd);
    	if (ret == 0)
    	{
    		printk("Trigger Command Successful.\n");
    		return true;
    	}
    	printk("Failed to trigger command %d: %d\n", cmd, ret);
    	return false;
    }
    
    int main(void)
    {
    	const struct device *const i2s_dev_rx = DEVICE_DT_GET(I2S_RX_NODE);
    	struct i2s_config config;
    
    	printk("I2S echo sample\n");
    
    	if (!device_is_ready(i2s_dev_rx))
    	{
    		printk("%s is not ready\n", i2s_dev_rx->name);
    		return 0;
    	}
    
    	config.word_size = SAMPLE_BIT_WIDTH;
    	config.channels = NUMBER_OF_CHANNELS;
    	config.format = I2S_FMT_DATA_FORMAT_I2S;
    	config.options = I2S_OPT_BIT_CLK_MASTER | I2S_OPT_FRAME_CLK_MASTER;
    	config.frame_clk_freq = SAMPLE_FREQUENCY;
    	config.mem_slab = &mem_slab;
    	config.block_size = BLOCK_SIZE;
    	config.timeout = TIMEOUT;
    
    	if (!configure_streams(i2s_dev_rx, &config))
    	{
    		return 0;
    	}
    
    	if (!trigger_command(i2s_dev_rx, I2S_TRIGGER_START))
    	{
    		return 0;
    	}
    
    	printk("Streams started\n");
    
    	while (1)
    	{
    		void *mem_block;
    		uint32_t block_size;
    		int ret;
    
    		ret = i2s_read(i2s_dev_rx, &mem_block, &block_size);
    		if (ret < 0)
    		{
    			printk("Failed to read data: %d\n", ret);
    			break;
    		}
    
    		process_block_data(mem_block, block_size);
    
    		// int16_t *data = (int16_t *)mem_block;
    		// for (size_t i = 0; i < block_size / sizeof(int16_t); i++)
    		// {
    		// 	printk("Data[%zu]: %d\n", i, data[i]);
    		// }
    
    		k_mem_slab_free(&mem_slab, mem_block);
    
    		printk("Loop: %d\n", loopCnt);
    		loopCnt++;
    	}
    	printk("Exiting main loop\n");
    	return 0;
    }

    I am getting,

    Starting nrf54l15dk with CPU frequency: 128 MHz
    I2S echo sample
    Failed to read data: -11
    Streams stopped

  • If you haven't already, can you just check that the default i2s examples work? 

    \zephyr\tests\drivers\i2s 

    Looks like both examples I can find there have overlay files for the nRF54L15.

    Kenneth

Reply Children
No Data
Related