<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://test-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>Configure EasyDMA + GPIOTE output + Timer</title><link>https://test-devzone.nordicsemi.com/f/nordic-q-a/88612/configure-easydma-gpiote-output-timer</link><description>Hi, I hope you had a nice weekend. 
 In my project, I basically need to output some data over GPIO from a memory buffer (highs and lows). Currently I&amp;#39;m doing this with a timer and ISR. The problem is that the timing must be accurate between each transmission</description><dc:language>en-US</dc:language><generator>Telligent Community 13 Non-Production</generator><lastBuildDate>Sat, 11 Jun 2022 15:59:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://test-devzone.nordicsemi.com/f/nordic-q-a/88612/configure-easydma-gpiote-output-timer" /><item><title>RE: Configure EasyDMA + GPIOTE output + Timer</title><link>https://test-devzone.nordicsemi.com/thread/371979?ContentTypeID=1</link><pubDate>Sat, 11 Jun 2022 15:59:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3de1346a-848c-4ad8-b022-62d8d45f0827</guid><dc:creator>user75799</dc:creator><description>&lt;p&gt;Thanks for the reply, Jared. After a bit more digging, the following code piece worked for me. I am sharing for others if somewhere needed.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;        nrfx_timer_clear(&amp;amp;m_timer1);
		nrfx_timer_clear(&amp;amp;m_timer2);
		nrfx_timer_resume(&amp;amp;m_timer1);
		nrfx_timer_resume(&amp;amp;m_timer2);
		k_sleep(K_MSEC(10));
		nrfx_timer_pause(&amp;amp;m_timer2);
		nrfx_timer_pause(&amp;amp;m_timer1);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In the timer2 event handler, I am updating the CC register of timer1, and it works &lt;span class="emoticon" data-url="https://test-devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static bool change[] = {true, false, false, true, false, false};
static volatile int idx = 0;
static volatile int cnt = 0;
static volatile bool skip = false;

void timer2_event_handler(nrf_timer_event_t event_type, void *p_context)
{
	switch (event_type)
	{
	case NRF_TIMER_EVENT_COMPARE0:
	{
		if (skip)
		{
			skip = false;
			break;
		}
		if (change[idx++])
		{
			skip = true;
			m_timer1.p_reg-&amp;gt;CC[NRF_TIMER_CC_CHANNEL0] = INTERVAL_US * 2;
		}
		else
		{
			m_timer1.p_reg-&amp;gt;CC[NRF_TIMER_CC_CHANNEL0] = INTERVAL_US;
		}
		idx %= 6;
		++cnt;
	}
	break;

	default:
		break;
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If&amp;nbsp;you have any better idea to do the same thing in another way, I would gladly test it and share the result here.&lt;/p&gt;
&lt;p&gt;Many thanks,&lt;/p&gt;
&lt;p&gt;Ozan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure EasyDMA + GPIOTE output + Timer</title><link>https://test-devzone.nordicsemi.com/thread/371561?ContentTypeID=1</link><pubDate>Thu, 09 Jun 2022 07:53:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f3021d1-604f-41ad-a269-3a1d811daad5</guid><dc:creator>user73165</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This was a very good explanation of what you want. &lt;span class="emoticon" data-url="https://test-devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
[quote user="ozanoner"] I can do that. But when it is active, updating CC makes it unstable.[/quote]
&lt;p&gt;But I&amp;#39;m wondering if you could elaborate on what happens when you load the CC when it&amp;#39;s active? Is it only unstable after the subsequent&amp;nbsp;events or the rest of the time after updating the CC. Have you verified that the CC register is loaded properly by reading it out with a debugger?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you using the&amp;nbsp;&lt;span&gt;nrfx_timer_compare() to load the new CC? What are you passing as the last parameter? &lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/55305292a2a8e4149869951451311452f4566e9a/drivers/src/nrfx_timer.c#L202"&gt;Note that the function call will clear any pending interrupts if it&amp;#39;s set to true.&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Jared&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure EasyDMA + GPIOTE output + Timer</title><link>https://test-devzone.nordicsemi.com/thread/371474?ContentTypeID=1</link><pubDate>Wed, 08 Jun 2022 15:17:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c709a35-86e1-4ff7-befc-a5d755abfd0c</guid><dc:creator>user75799</dc:creator><description>&lt;p&gt;Thanks for the reply, Jared!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Unfortunately, I have to go with GPIOTE.&lt;/p&gt;
&lt;p&gt;Now, I have such a configuration:&lt;/p&gt;
&lt;p&gt;- I have timer1,&amp;nbsp;generating compare event every 420us.&lt;/p&gt;
&lt;p&gt;- I have a PPI configured to connect timer1-compare to GPIOTE-toggle task.&lt;/p&gt;
&lt;p&gt;So I have a regular pattern HIGH and LOW, alternating every 420us.&lt;/p&gt;
&lt;p&gt;My question is now, can I update timer1-CC register while it is running (while still generating compare events) to, let&amp;#39;s say, 840us, so that I can have different HIGH/LOW patterns instead of toggling every 420us?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When timer1 is not active (&amp;nbsp;&lt;code&gt;&lt;span&gt;nrfx_timer_pause&lt;/span&gt;&lt;span&gt;(&amp;amp;&lt;/span&gt;&lt;span&gt;m_timer1&lt;/span&gt;&lt;/code&gt;&lt;span&gt;&lt;code&gt;)&lt;/code&gt; ) , I can do that. But when it is active, updating CC makes it unstable.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What I have:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;420us&amp;nbsp; &amp;nbsp;&lt;span&gt;420us&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;420us&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;420us&amp;nbsp;&amp;nbsp;420us&amp;nbsp;&amp;nbsp;420us&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;HIGH&amp;nbsp; &amp;nbsp; LOW&amp;nbsp; &amp;nbsp;HIGH&amp;nbsp; &amp;nbsp;LOW&amp;nbsp; &amp;nbsp;&lt;span&gt;HIGH&amp;nbsp; &amp;nbsp;LOW&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;pause here then set CC to 840us, then resume:&lt;/p&gt;
&lt;p&gt;420us&amp;nbsp; &amp;nbsp;&lt;span&gt;420us&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;420us&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;420us&amp;nbsp;&amp;nbsp;420us&amp;nbsp;&amp;nbsp;420us&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;HIGH&amp;nbsp; &amp;nbsp; HIGH&amp;nbsp; &amp;nbsp;LOW&amp;nbsp; &amp;nbsp;LOW&amp;nbsp; &amp;nbsp;&lt;span&gt;HIGH&amp;nbsp; &amp;nbsp;HIGH&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What I want to have:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;420us&amp;nbsp; &amp;nbsp;&lt;span&gt;420us&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;420us&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;420us&amp;nbsp;&amp;nbsp;420us&amp;nbsp;&amp;nbsp;420us&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;HIGH&amp;nbsp; &amp;nbsp;HIGH&amp;nbsp; &amp;nbsp; LOW &amp;nbsp; LOW&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span&gt;HIGH&amp;nbsp; &amp;nbsp;LOW&amp;nbsp; &amp;nbsp; &amp;nbsp;(and any random combination of HIGHs/LOWs based on&amp;nbsp;compare&amp;nbsp;value without pausing timer1)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is&amp;nbsp;this possible?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks again for the help.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Ozan&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure EasyDMA + GPIOTE output + Timer</title><link>https://test-devzone.nordicsemi.com/thread/371176?ContentTypeID=1</link><pubDate>Tue, 07 Jun 2022 13:31:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26036f41-90eb-42b9-a7c1-b7fd6c37ef19</guid><dc:creator>user73165</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]&lt;p&gt;-&amp;nbsp;Each time a timer event occurs (with exactly 420us intervals), move a bit (high/low value) from DMA buffer (I think it is an ArrayList) to GPIO output.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;You can either set the pin high, set the pin low, or toggle it with GPIOTE. The task that is connected through the PPI can&amp;#39;t be decided based on the memory buffer. In other words, a specific event needs to be connected to a specific task before run time.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Maybe you could use SPIM with PPI?&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>