<?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>QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91398/qdec-peripheral-with-high-speed-encoder</link><description>Hello, 
 I have been testing an encoder using the QDEC peripheral. 
 The encoder produces 256 pulses per rotation. Testing without any load assigned to the motor, the encoder rotates at 2000-3000 rpm depending on the input. 
 Using the zephyr sensor api</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Sep 2022 14:12:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91398/qdec-peripheral-with-high-speed-encoder" /><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/386932?ContentTypeID=1</link><pubDate>Mon, 19 Sep 2022 14:12:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dcca281-9cd8-46f5-af70-d83879358898</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Assuming you set the timer to 32-bit mode it should take a long time between each overflow. A simple way to detect overflow is to store the previous counter&amp;nbsp;value in a static variable, and compare the&amp;nbsp;previous counter to the current one. If the previous counter is larger than the current then you know that an overflow occurred, and you can calculate the difference between the two.&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/386729?ContentTypeID=1</link><pubDate>Sat, 17 Sep 2022 08:53:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e44b02d-020f-41ec-864e-9e94c46b9092</guid><dc:creator>pekon94</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;you are right. I had a misunderstanding on this.&lt;/p&gt;
&lt;p&gt;I have implemented this and it seems to be working fine.&lt;/p&gt;
&lt;p&gt;I have not added a direction check yet but I will explore adding this too.&lt;/p&gt;
&lt;p&gt;I am now trying to see what is the best way to capture the counter value (considering that if I clear every capture, I might miss some counts. On the other hand if I do not clear, I will need to find a way to handle the possible overflow of the counter register).&lt;/p&gt;
&lt;p&gt;You may consider this answered.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/386638?ContentTypeID=1</link><pubDate>Fri, 16 Sep 2022 12:11:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c75afff5-3caf-440e-8a13-d2ac301c5e12</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you have 2 different pins you would also need 2 different GPIOTE channels, but possibly I am misunderstanding the issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you are still unsure why you have to configure the GPIOTE driver the way you do, maybe you can share your init code and I can have a look at it?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/385973?ContentTypeID=1</link><pubDate>Tue, 13 Sep 2022 13:00:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22801145-14ff-4670-b366-1536e86d73bc</guid><dc:creator>pekon94</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;no I am expanding this for 2 encoders, so I am using a IN_EVENT configured for 2 different PINs upon a LOTOHI event.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/385971?ContentTypeID=1</link><pubDate>Tue, 13 Sep 2022 12:56:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7f7b373-2792-470b-b6f1-ee4e48f85f16</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you need separate events for a rising and falling flank it makes sense that you would need to use 2 channels, the GPIOTE hardware does not support generating different events on a single channel.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is this what you were trying to do?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/385805?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2022 17:52:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86258d85-1724-4c6b-bccc-ee6bd93d79b6</guid><dc:creator>pekon94</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;thank you for this.&lt;/p&gt;
&lt;p&gt;I used the nrfx_gpiote_input_configure() function and the nrfx_gpiote_trigger_enable() function. In the second one I had the int_enable parameter set to false.&lt;/p&gt;
&lt;p&gt;I noticed though that I had to allocate 2x GPIOTE channels (could not let the nrfx_gpiote_trigger_config_t p_in_channel parameter set to NULL) and add CONFIG_NRFX_GPIOTE_NUM_OF_EVT_HANDLERS=2 in the prj.conf file to make it work. &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/385664?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2022 09:20:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d79c08b0-5a78-4f96-ab1f-0e7ea195e5b5</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
[quote user="pekon94"]Is there another way to initialize the PIN in GPIOTE IN_EVENT mode ? I tried leaving the event_handler as NULL but this caused the CPU to crash and reboot upon any event.[/quote]
&lt;p&gt;The&lt;em&gt; nrfx_gpiote_in_init(..)&lt;/em&gt; function has been deprecated, and you should use the &lt;em&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfx/drivers/gpiote/driver.html?highlight=nrfx_gpiote#c.nrfx_gpiote_input_configure"&gt;nrfx_gpiote_input_configure(..)&lt;/a&gt; &lt;/em&gt;function instead.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;With this function it should be possible to set the&amp;nbsp;&lt;em&gt;p_handler_config&lt;/em&gt; argument to NULL, in order to disable the interrupt.&amp;nbsp;&lt;/p&gt;
[quote user="pekon94"]&lt;p&gt;I was also wondering if the GPIOTE and TIMER initialization and enable sequence is the correct one.&lt;/p&gt;
&lt;p&gt;Am I correct to assume that I should initialize them before connecting them with dppi but enable them after connecting them with dppi ?&lt;/p&gt;[/quote]
&lt;p&gt;The natural order is to configure the peripherals first, then make the various DPPI connections, and&amp;nbsp;starting peripherals that need to be started at the very end.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/385432?ContentTypeID=1</link><pubDate>Fri, 09 Sep 2022 07:47:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90e66dd8-c134-4e45-8efc-2da2dc979e89</guid><dc:creator>pekon94</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I finally got a piece of code working (tested with another encoder) and I intend to use it today with the encoder mentioned above.&lt;/p&gt;
&lt;p&gt;However I have the following question:&lt;/p&gt;
&lt;p&gt;As you can see, in order to initialize the PIN in GPIOTE IN_EVENT mode I had to declare an event handler function. I have left it empty, but isn&amp;#39;t this also causing a CPU interrupt ?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void event_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
}

static void cust_qdec_init(void)
{
	IRQ_CONNECT(DT_IRQN(DT_NODELABEL(gpiote)),
		    DT_IRQ(DT_NODELABEL(gpiote), priority),
		    nrfx_isr, nrfx_gpiote_irq_handler, 0);

	printk(&amp;quot;Helloooooooooo\n&amp;quot;);
	timer_cfg.bit_width = NRF_TIMER_BIT_WIDTH_32 ;
	timer_cfg.mode = NRF_TIMER_MODE_COUNTER ;
	pina_config.pull = NRF_GPIO_PIN_NOPULL;

	printk(&amp;quot;1111111111111111\n&amp;quot;);
	err_code = nrfx_timer_init(&amp;amp;qdec_time_counter, &amp;amp;timer_cfg, NULL);
	if (err_code != NRFX_SUCCESS) {
		printk(&amp;quot;Error in timer initialization !!!! \n&amp;quot;);
		return;
	}
	nrfx_timer_enable(&amp;amp;qdec_time_counter);
	printk(&amp;quot;222222222222222\n&amp;quot;);
	if (!nrfx_gpiote_is_init()) {
		err_code = nrfx_gpiote_init(0);
		if (err_code != NRFX_SUCCESS) {
			printk(&amp;quot;Error in NRFX GPIOTE initialization !!!! \n&amp;quot;);
			return;
		}
	}
	err_code = nrfx_gpiote_in_init(PINA, &amp;amp;pina_config, event_handler);
  if (err_code != NRFX_SUCCESS) {
    printk(&amp;quot;Error in GPIOTE IN_EVENT configuration Initialization&amp;quot;);
    return;
  }

	err_code = nrfx_dppi_channel_alloc(&amp;amp;cust_qdec_ppi_chann);
  if (err_code != NRFX_SUCCESS) {
    printk (&amp;quot;Error in allocating DPPI channel \n&amp;quot;);
    return;
  }
	nrfx_gppi_channel_endpoints_setup(cust_qdec_ppi_chann,
                                     nrfx_gpiote_in_event_addr_get(PINA),
                                     nrfx_timer_task_address_get(&amp;amp;qdec_time_counter, NRF_TIMER_TASK_COUNT));
  if (err_code != NRFX_SUCCESS) {
    printk(&amp;quot;Eroor in configuring GPPI endpoints \n&amp;quot;);
    return;
  }
	err_code = nrfx_dppi_channel_enable(cust_qdec_ppi_chann);
  if (err_code != NRFX_SUCCESS) {
    printk(&amp;quot;Error enabling the DPPI Channel for qdec \n&amp;quot;);
    return;
  }
	nrfx_gpiote_in_event_enable(PINA,true);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Is there another way to initialize the PIN in GPIOTE IN_EVENT mode ? I tried leaving the event_handler as NULL but this caused the CPU to crash and reboot upon any event.&lt;/p&gt;
&lt;p&gt;I was also wondering if the GPIOTE and TIMER initialization and enable sequence is the correct one.&lt;/p&gt;
&lt;p&gt;Am I correct to assume that I should initialize them before connecting them with dppi but enable them after connecting them with dppi ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/384594?ContentTypeID=1</link><pubDate>Mon, 05 Sep 2022 13:12:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5269b08-8ce2-4709-b007-cec70f4dcaac</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There is no direct way to find out if an interrupt is delayed unfortunately. You might be able to do some benchmarking and testing to verify whether or not there are any interrupts in the system that could delay you long enough to miss the value of PINB.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Alternatively you could implement a more complex system where you connect both the PINA and PINB inputs to capture on different CC registers of a timer, and use this to analyze if PINB goes low or high following a rising flank on PINA.&amp;nbsp;&lt;/p&gt;
[quote user="pekon94"]would it be a solution to increase the APP core frequency (to 128Mhz) ?[/quote]
&lt;p&gt;Not a solution necessarily, but increasing the app core frequency should reduce the runtime of the various interrupts, and also reduce the interrupt latency.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/384446?ContentTypeID=1</link><pubDate>Sat, 03 Sep 2022 11:58:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3843913-720d-4742-a34d-f1798e4dc4a4</guid><dc:creator>pekon94</dc:creator><description>&lt;p&gt;Hello Ovrebekk,&lt;/p&gt;
&lt;p&gt;would it be a solution to increase the APP core frequency (to 128Mhz) ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/384293?ContentTypeID=1</link><pubDate>Thu, 01 Sep 2022 09:41:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:401a0d54-1c1d-4c46-8505-a81ec2fcf1aa</guid><dc:creator>pekon94</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I can do that considering the direction equal to the motor control direction and use it to calculate the position combining this and the displacement.&lt;/p&gt;
&lt;p&gt;Considering this the interrupt routine will only include a counter increase and not any time consuming process.&lt;/p&gt;
&lt;p&gt;I will try this and if it works I will update here for the record.&lt;/p&gt;
&lt;p&gt;How could I check whether the interrupt is delayed ?&lt;/p&gt;
&lt;p&gt;Thanks again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/384269?ContentTypeID=1</link><pubDate>Thu, 01 Sep 2022 08:14:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a1d8ff7-d08b-4b0f-a7dc-8421622fa368</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you can exclude it it would definitely simplify the implementation,&amp;nbsp;but possibly it is enough to occasionally trigger an interrupt on the PINA event and check the status of PINB. You just need some system to detect if the interrupt is delayed, since this would give you an incorrect reading.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/384169?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 13:56:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2d9b24e-40c5-465d-9da7-7387830bffac</guid><dc:creator>pekon94</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;ideally I would need to be able to capture displacement in both directions.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I was thinking of checking this by capturing the PINB status whenever the PINA GPIOTE event occurs.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;On the other hand, direction is something that perhaps I would be able to exclude considering that I will be controlling the motor&amp;#39;s rotation and therefore I can try considering the actual direction equal to the command direction I set (in order to avoid the need for calculating the direction through the encoder).&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/384165?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 13:46:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c146f778-93e6-4f01-a480-d343b08cd197</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;That changes things. Hopefully you only need to detect displacement in one direction?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You could change the TIMER module to counter mode, and instead of measuring the time between two consecutive GPIOTE IN events simply count how many times each of them occur. Then you can set up a separate slower timer (using an RTC or Zephyr timer) to run a capture on the timer and read out the value at regular intervals.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As long as you have 2 free TIMER modules, and an additional GPIOTE and PPI channel, you should be able to serve 2 encoders.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/384073?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 08:36:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8817836-2ab9-47b6-a21e-02b082fe338d</guid><dc:creator>pekon94</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;this is what is causing me trouble at the moment.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I need to calculate displacement not speed and my project requires 2 encoders in total.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Considering you solution I am not sure how to use it to calculate displacement.&lt;/p&gt;
&lt;p&gt;I think that the only way to capture displacement and understand direction will be to capture each pulse.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/384065?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 08:07:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17c34183-cbd6-48ae-a50b-57731597ce18</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You welcome, glad I could help.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you find this method to work sufficiently well I would recommend rewriting the code using the nrfx drivers. There should be an nrfx driver available for the TIMER, DPPI and GPIOTE modules.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tested my code simply by calling the pulse_capture_get() function at regular intervals on a timer, but you can also enable interrupt on the GPIOTE IN event in case you want to be interrupted on every pulse. The problem with this is that you will get a very large number of interrupts, as you already discovered.&amp;nbsp;&lt;br /&gt;Potentially you can make a hybrid solution where you enable interrupts when the motor speed is low, and change to a polling solution when the motor frequency passes a certain threshold, to avoid an unpredictable and variable load on the CPU to handle all the interrupts.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/383878?ContentTypeID=1</link><pubDate>Tue, 30 Aug 2022 11:17:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8904695-5fa5-4ff9-a99d-13819ae90fc3</guid><dc:creator>pekon94</dc:creator><description>&lt;p&gt;Hello Ovrebekk,&lt;/p&gt;
&lt;p&gt;thank you for your answer and for confirming this.&lt;/p&gt;
&lt;p&gt;Also thank you for sharing this sample.&lt;/p&gt;
&lt;p&gt;I will read more about the TIMER and GPIOTE peripherals since I have never used them before and I will try to implement this.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/383870?ContentTypeID=1</link><pubDate>Tue, 30 Aug 2022 10:51:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc672bae-1753-4d35-8209-6776a06e2206</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If my math is correct you will get pulses every 80us (meaning a rising or falling flank every 40us) when the encoder is rotating at 3000 RPM with 256 pulses pr rotation. This is too fast for the QDEC, even at its fastest setting.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It is true that you can use the GPIOTE, TIMER and PPI peripherals to measure the length of a pulse without having to rapidly process an interrupt. A simple way to do this is simply to have a free running timer that will trigger a capture and clear every time you get a pulse, and the CC register will then change depending on how long time it takes between captures.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The simple example included below (written for the nRF52 series originally) illustrates this concept. To run on the nRF5340 it will need some rewriting because of the difference between the PPI and DPPI peripherals.&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define PC_TIMER		NRF_TIMER0
#define PC_GPIOTE_CH	0
#define PC_PPI_CH		0

static void pulse_capture_init(uint32_t pin_num)
{
	PC_TIMER-&amp;gt;BITMODE = TIMER_BITMODE_BITMODE_32Bit &amp;lt;&amp;lt; TIMER_BITMODE_BITMODE_Pos;
	PC_TIMER-&amp;gt;PRESCALER = 0;
	NRF_GPIOTE-&amp;gt;CONFIG[PC_GPIOTE_CH] = 	GPIOTE_CONFIG_MODE_Event &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos |
										GPIOTE_CONFIG_POLARITY_LoToHi &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos |
										pin_num &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos;
	NRF_PPI-&amp;gt;CH[PC_PPI_CH].EEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;EVENTS_IN[PC_GPIOTE_CH];
	NRF_PPI-&amp;gt;CH[PC_PPI_CH].TEP = (uint32_t)&amp;amp;PC_TIMER-&amp;gt;TASKS_CAPTURE[0];
	NRF_PPI-&amp;gt;FORK[PC_PPI_CH].TEP = (uint32_t)&amp;amp;PC_TIMER-&amp;gt;TASKS_CLEAR;
	NRF_PPI-&amp;gt;CHENSET = (1 &amp;lt;&amp;lt; PC_PPI_CH);

	PC_TIMER-&amp;gt;TASKS_START = 1;
}

static uint32_t pulse_capture_get()
{
	return PC_TIMER-&amp;gt;CC[0];
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC Peripheral with high speed encoder</title><link>https://devzone.nordicsemi.com/thread/383663?ContentTypeID=1</link><pubDate>Mon, 29 Aug 2022 11:50:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b84fa2e-6656-4bea-866b-204944286584</guid><dc:creator>Kaja</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;an engineer will be assigned to your case tomorrow.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Kaja&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>