<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nrf52840 QFAA easydma</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/126163/nrf52840-qfaa-easydma</link><description>I am using the nrf52840 in QFAA package, and the external DMIC example receives audio data through the PDM interface. I noticed that the official documentation mentions support for EasyDMA. How can I use the DMA mechanism, and are there any related example</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 18 Dec 2025 03:29:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/126163/nrf52840-qfaa-easydma" /><item><title>RE: nrf52840 QFAA easydma</title><link>https://devzone.nordicsemi.com/thread/557282?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2025 03:29:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0de1db6a-e78a-4846-9ea3-7270ea9017a2</guid><dc:creator>rashfords</dc:creator><description>&lt;p&gt;Thank you! The problem is solved.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 QFAA easydma</title><link>https://devzone.nordicsemi.com/thread/557250?ContentTypeID=1</link><pubDate>Wed, 17 Dec 2025 15:56:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05eda123-72bb-4206-b645-d32bd33a0a46</guid><dc:creator>Maria Gilje</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you tried to run the sample in a debugging session like Turbo J suggested?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Maria&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 QFAA easydma</title><link>https://devzone.nordicsemi.com/thread/557082?ContentTypeID=1</link><pubDate>Tue, 16 Dec 2025 12:06:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abd3d5bf-6a35-4845-83f4-cb5a4c03e7b0</guid><dc:creator>rashfords</dc:creator><description>&lt;p&gt;Are you saying DMA is enabled without any configuration? The example code can be flashed normally, but it doesn&amp;#39;t seem to be using the DMA mechanism, right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 QFAA easydma</title><link>https://devzone.nordicsemi.com/thread/557078?ContentTypeID=1</link><pubDate>Tue, 16 Dec 2025 11:52:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8a1d69d-e953-459c-ad21-8aa39d1738f1</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;It very much &lt;em&gt;does&lt;/em&gt; use DMA internally since that is the&amp;nbsp;&lt;em&gt;only way&lt;/em&gt; you can actually get audio data out of the peripherial.&lt;/p&gt;
&lt;p&gt;Code above does not show anything that is actually happening in drivers. Try running it in a debugger.&lt;/p&gt;
&lt;p&gt;I strongly recommend using the driver (and not NRFX stuff directly) here as it solves the otherwise non- trivial audio buffering issues.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 QFAA easydma</title><link>https://devzone.nordicsemi.com/thread/557054?ContentTypeID=1</link><pubDate>Tue, 16 Dec 2025 09:08:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97b5364b-f84c-4a13-901e-341918fba7c9</guid><dc:creator>rashfords</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2021 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/audio/dmic.h&amp;gt;
#include &amp;lt;zephyr/logging/log.h&amp;gt;
LOG_MODULE_REGISTER(dmic_sample);

#define MAX_SAMPLE_RATE  16000
#define SAMPLE_BIT_WIDTH 16
#define BYTES_PER_SAMPLE sizeof(int16_t)
/* Milliseconds to wait for a block to be read. */
#define READ_TIMEOUT     1000

/* Size of a block for 100 ms of audio data. */
#define BLOCK_SIZE(_sample_rate, _number_of_channels) \
	(BYTES_PER_SAMPLE * (_sample_rate / 10) * _number_of_channels)

/* Driver will allocate blocks from this slab to receive audio data into them.
 * Application, after getting a given block from the driver and processing its
 * data, needs to free that block.
 */
#define MAX_BLOCK_SIZE   BLOCK_SIZE(MAX_SAMPLE_RATE, 2)
#define BLOCK_COUNT      4
K_MEM_SLAB_DEFINE_STATIC(mem_slab, MAX_BLOCK_SIZE, BLOCK_COUNT, 4);

static int do_pdm_transfer(const struct device *dmic_dev,
			   struct dmic_cfg *cfg,
			   size_t block_count)
{
	int ret;

	LOG_INF(&amp;quot;PCM output rate: %u, channels: %u&amp;quot;,
		cfg-&amp;gt;streams[0].pcm_rate, cfg-&amp;gt;channel.req_num_chan);

	ret = dmic_configure(dmic_dev, cfg);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to configure the driver: %d&amp;quot;, ret);
		return ret;
	}

	ret = dmic_trigger(dmic_dev, DMIC_TRIGGER_START);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;START trigger failed: %d&amp;quot;, ret);
		return ret;
	}

	for (int i = 0; i &amp;lt; block_count; ++i) {
		void *buffer;
		uint32_t size;

		ret = dmic_read(dmic_dev, 0, &amp;amp;buffer, &amp;amp;size, READ_TIMEOUT);
		if (ret &amp;lt; 0) {
			LOG_ERR(&amp;quot;%d - read failed: %d&amp;quot;, i, ret);
			return ret;
		}

		LOG_INF(&amp;quot;%d - got buffer %p of %u bytes&amp;quot;, i, buffer, size);

		k_mem_slab_free(&amp;amp;mem_slab, buffer);
	}

	ret = dmic_trigger(dmic_dev, DMIC_TRIGGER_STOP);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;STOP trigger failed: %d&amp;quot;, ret);
		return ret;
	}

	return ret;
}

int main(void)
{
	const struct device *const dmic_dev = DEVICE_DT_GET(DT_NODELABEL(dmic_dev));
	int ret;

	LOG_INF(&amp;quot;DMIC sample&amp;quot;);

	if (!device_is_ready(dmic_dev)) {
		LOG_ERR(&amp;quot;%s is not ready&amp;quot;, dmic_dev-&amp;gt;name);
		return 0;
	}

	struct pcm_stream_cfg stream = {
		.pcm_width = SAMPLE_BIT_WIDTH,
		.mem_slab  = &amp;amp;mem_slab,
	};
	struct dmic_cfg cfg = {
		.io = {
			/* These fields can be used to limit the PDM clock
			 * configurations that the driver is allowed to use
			 * to those supported by the microphone.
			 */
			.min_pdm_clk_freq = 1000000,
			.max_pdm_clk_freq = 3500000,
			.min_pdm_clk_dc   = 40,
			.max_pdm_clk_dc   = 60,
		},
		.streams = &amp;amp;stream,
		.channel = {
			.req_num_streams = 1,
		},
	};

	cfg.channel.req_num_chan = 1;
	cfg.channel.req_chan_map_lo =
		dmic_build_channel_map(0, 0, PDM_CHAN_LEFT);
	cfg.streams[0].pcm_rate = MAX_SAMPLE_RATE;
	cfg.streams[0].block_size =
		BLOCK_SIZE(cfg.streams[0].pcm_rate, cfg.channel.req_num_chan);

	ret = do_pdm_transfer(dmic_dev, &amp;amp;cfg, 2 * BLOCK_COUNT);
	if (ret &amp;lt; 0) {
		return 0;
	}

	cfg.channel.req_num_chan = 2;
	cfg.channel.req_chan_map_lo =
		dmic_build_channel_map(0, 0, PDM_CHAN_LEFT) |
		dmic_build_channel_map(1, 0, PDM_CHAN_RIGHT);
	cfg.streams[0].pcm_rate = MAX_SAMPLE_RATE;
	cfg.streams[0].block_size =
		BLOCK_SIZE(cfg.streams[0].pcm_rate, cfg.channel.req_num_chan);

	ret = do_pdm_transfer(dmic_dev, &amp;amp;cfg, 2 * BLOCK_COUNT);
	if (ret &amp;lt; 0) {
		return 0;
	}

	LOG_INF(&amp;quot;Exiting&amp;quot;);
	return 0;
}
&lt;/pre&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1765876110704v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;The official example code does not use DMA. The datasheet for the nRF52840 only covers the hardware configuration for this part and does not provide specific configuration functions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 QFAA easydma</title><link>https://devzone.nordicsemi.com/thread/557051?ContentTypeID=1</link><pubDate>Tue, 16 Dec 2025 08:58:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3cc3ee6f-75c5-47f4-9b27-52bf2ce4b788</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;There is a &amp;quot;DMIC&amp;quot; audio sample in NCS SDK that should demonstrate how to use the driver interface.&lt;/p&gt;
&lt;p&gt;DMA is used internally by the driver.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>