<?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 - nRF52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89950/qdec---nrf52840</link><description>Hi, 
 
 I&amp;#39;m working through the QDEC using the nRF2840 evaluation board and I&amp;#39;ve run into some confusion. 
 
 
 I have trouble getting the ACC or ACCREAD registers to actually accumulate over time. If I want to keep track of increments, I have to record</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Jul 2022 17:26:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89950/qdec---nrf52840" /><item><title>RE: QDEC - nRF52840</title><link>https://devzone.nordicsemi.com/thread/377034?ContentTypeID=1</link><pubDate>Thu, 14 Jul 2022 17:26:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9cc4956-1387-4de0-931f-69c0841e4d17</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I don&amp;#39;t want to comment on why it&amp;#39;s implemented the way it is. Have in mind though that the implementation ensure no movement is lost when using the&amp;nbsp;&lt;span&gt;READCLRACC&amp;nbsp;or&amp;nbsp;RDCLRACC tasks.&lt;/span&gt;&lt;/p&gt;
[quote user="Dude_eh"]Is it possible to trigger an interrupt event given an invalid state transition? If so, how? What is the NRF_QDEC_EVENT_????? reference for it?&amp;nbsp;[/quote]
&lt;p&gt;You can connect the&amp;nbsp;DBLRDY&amp;nbsp;event to the EGU peripheral to trigger a EGU interrupt, then when you receive this interrupt you will then know that it is triggered by the DBLRDY event.&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/egu.html"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/egu.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC - nRF52840</title><link>https://devzone.nordicsemi.com/thread/376852?ContentTypeID=1</link><pubDate>Wed, 13 Jul 2022 21:01:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:523fdb46-b593-4079-b9a2-388854582947</guid><dc:creator>Canadian_EE</dc:creator><description>&lt;blockquote&gt;
&lt;p class="quote-content"&gt;The documentation says that the QDEC samples at a rate of 1MHz. I&amp;#39;m guessing the device uses oversampling, scaling this 1uS rate down to 128uS because the smallest SAMPLEPER you can select is 128uS.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;How does this change if I select debounce enabled?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="quote-footer"&gt;&lt;/p&gt;
&lt;p&gt;There is no oversampling if debounce is not enabled, ref:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;span&gt;The QDEC decodes the output from the off-chip encoder by sampling the QDEC phase input pins (A and B) at a fixed rate as specified in the SAMPLEPER register.&lt;/span&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;If debounce is enabled, then this changes, ref:&lt;/p&gt;
&lt;p&gt;&amp;quot;When enabled through the DBFEN register, the filter inputs are sampled at a fixed 1 MHz frequency during the entire sample period (which is specified in the SAMPLEPER register). The filters require all of the samples within this sample period to equal before the input signal is accepted and transferred to the output of the filter.&lt;/p&gt;
&lt;p&gt;As a result, only input signal with a steady state longer than twice the period specified in SAMPLEPER are guaranteed to pass through the filter.&amp;quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If the system is sampling at a rate of 1MHz or .5MHz, than why is a sample generated only every 128uS? That would suggest some processing is occurring in the additional 126 or 127uS; depending on whether it is sampled once or twice with debounce.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;*********&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;div class="quote-content"&gt;Given debounce enabled, does the system still evaluate a sample every 128uS? Or is it every 258uS?&lt;/div&gt;
&lt;div class="quote-footer"&gt;&lt;/div&gt;
&lt;p&gt;See above.&lt;/p&gt;
&lt;div class="quote-header"&gt;&lt;/div&gt;
&lt;div class="quote-content"&gt;Given debounce enabled, is ACC still delayed by one sample, as mentioned in the QDEC documentation?&lt;/div&gt;
&lt;div class="quote-footer"&gt;&lt;/div&gt;
&lt;p&gt;I can only find there is a delay when debounce is enabled yes:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;When the debounce filters are enabled, displacements reported by the QDEC peripheral are delayed by one SAMPLEPER period.&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When I read ACCREAD, is ACCREAD off by up to one increment given debounce enabled?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;********&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;div class="quote-content"&gt;Does ACC and or accread get cleared every time I go to read it with a nrf_qdec_accread_get() function?&lt;/div&gt;
&lt;div class="quote-footer"&gt;&lt;/div&gt;
&lt;p&gt;Looking at the implementation of&amp;nbsp;&lt;span&gt;nrf_qdec_accread_get() I can find it simply return&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_QDEC&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;ACCREAD;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;According to documentation this register is only updated using either of the two tasks&amp;nbsp;READCLRACC&amp;nbsp;or&amp;nbsp;RDCLRACC&amp;nbsp;. Both these tasks also clear the ACC register, ref:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;The ACC and ACCDBL registers can be cleared by the READCLRACC and subsequently read using the ACCREAD and ACCDBLREAD registers.&lt;/p&gt;
&lt;p&gt;The ACC register can be separately cleared by the RDCLRACC and subsequently read using the ACCREAD registers.&amp;quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; So then what you are saying is for &amp;quot;nrf_qdec_accread_get()&amp;quot; to get the most recent value, in must be clearing ACC in the process...?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;***************&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;div class="quote-content"&gt;&amp;nbsp; &amp;nbsp; I don&amp;#39;t want to have ongoing interrupts to manage this hardware peripheral. I want it to accumulate on its own, requiring servicing perhaps only if there is an overflow or an invalid state transition. How does Nordic recommend enabling this behavior?&lt;/div&gt;
&lt;div class="quote-footer"&gt;&lt;/div&gt;
&lt;p&gt;It&amp;#39;s possible to read the ACC and ACCDBL register directly (instead of using executing above mention tasks that clear them), but be aware the max value for those two registers are +-1024. So I am not sure it&amp;#39;s a good idea to let them run for a long time before clearing them.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; I would like the system to accumulate, but not require an interrupt for it to update ACCREAD every time a movement occurs. Are you saying this isn&amp;#39;t possible without interrupts? For instance, I couldn&amp;#39;t get the DMA to update ACCREAD? Not simply just to copy ACC into ACCREAD then&amp;nbsp; clear ACC, but to add the current value of ACC into ACCREAD then clear ACC.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;******************&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Is it possible to trigger an interrupt event given an invalid state transition? If so, how? What is the NRF_QDEC_EVENT_????? reference for it?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;No.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The documentation mentions a &amp;quot;DBLRDY&amp;quot; event in the occurrence of one or more invalid transitions. How do I make this event trigger an interrupt? If it is an event, shouldn&amp;#39;t that mean I can make it cause an interrupt...?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Let me know, thanks. Also, please see the documentation at&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fqdec.html"&gt;Nordic Semiconductor Infocenter&lt;/a&gt;&amp;nbsp;regarding the DBLRDY event.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC - nRF52840</title><link>https://devzone.nordicsemi.com/thread/376850?ContentTypeID=1</link><pubDate>Wed, 13 Jul 2022 20:21:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14d3f396-ce52-4df1-860b-c071671d3c88</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi again,&lt;/p&gt;
&lt;p&gt;My take on your questions:&lt;/p&gt;
[quote user=""]The documentation says that the QDEC samples at a rate of 1MHz. I&amp;#39;m guessing the device uses oversampling, scaling this 1uS rate down to 128uS because the smallest SAMPLEPER you can select is 128uS.
&lt;ol&gt;
&lt;li&gt;How does this change if I select debounce enabled?&lt;/li&gt;&lt;/ol&gt;[/quote]
&lt;p&gt;There is no oversampling if debounce is not enabled, ref:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;span&gt;The QDEC decodes the output from the off-chip encoder by sampling the QDEC phase input pins (A and B) at a fixed rate as specified in the SAMPLEPER register.&lt;/span&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;If debounce is enabled, then this changes, ref:&lt;/p&gt;
&lt;p&gt;&amp;quot;When enabled through the DBFEN register, the filter inputs are sampled at a fixed 1 MHz frequency during the entire sample period (which is specified in the SAMPLEPER register). The filters require all of the samples within this sample period to equal before the input signal is accepted and transferred to the output of the filter.&lt;/p&gt;
&lt;p&gt;As a result, only input signal with a steady state longer than twice the period specified in SAMPLEPER are guaranteed to pass through the filter.&amp;quot;&lt;/p&gt;
[quote user=""]Given debounce enabled, does the system still evaluate a sample every 128uS? Or is it every 258uS?[/quote]
&lt;p&gt;See above.&lt;/p&gt;
[quote user=""]Given debounce enabled, is ACC still delayed by one sample, as mentioned in the QDEC documentation?[/quote]
&lt;p&gt;I can only find there is a delay when debounce is enabled yes:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;When the debounce filters are enabled, displacements reported by the QDEC peripheral are delayed by one SAMPLEPER period.&amp;quot;&lt;/span&gt;&lt;/p&gt;
[quote user=""]Does ACC and or accread get cleared every time I go to read it with a nrf_qdec_accread_get() function?[/quote]
&lt;p&gt;Looking at the implementation of&amp;nbsp;&lt;span&gt;nrf_qdec_accread_get() I can find it simply return&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_QDEC&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;ACCREAD;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;According to documentation this register is only updated using either of the two tasks&amp;nbsp;READCLRACC&amp;nbsp;or&amp;nbsp;RDCLRACC&amp;nbsp;. Both these tasks also clear the ACC register, ref:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;The ACC and ACCDBL registers can be cleared by the READCLRACC and subsequently read using the ACCREAD and ACCDBLREAD registers.&lt;/p&gt;
&lt;p&gt;The ACC register can be separately cleared by the RDCLRACC and subsequently read using the ACCREAD registers.&amp;quot;&lt;/p&gt;
[quote user=""]&amp;nbsp; &amp;nbsp; I don&amp;#39;t want to have ongoing interrupts to manage this hardware peripheral. I want it to accumulate on its own, requiring servicing perhaps only if there is an overflow or an invalid state transition. How does Nordic recommend enabling this behavior?[/quote]
&lt;p&gt;It&amp;#39;s possible to read the ACC and ACCDBL register directly (instead of using executing above mention tasks that clear them), but be aware the max value for those two registers are +-1024. So I am not sure it&amp;#39;s a good idea to let them run for a long time before clearing them.&lt;/p&gt;
[quote user=""]Is it possible to trigger an interrupt event given an invalid state transition? If so, how? What is the NRF_QDEC_EVENT_????? reference for it?&amp;nbsp;[/quote]
&lt;p&gt;No.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC - nRF52840</title><link>https://devzone.nordicsemi.com/thread/376842?ContentTypeID=1</link><pubDate>Wed, 13 Jul 2022 18:16:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b92b43ee-4520-4f8e-bbd3-d33fd675b80e</guid><dc:creator>Canadian_EE</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; I have gone through the QDEC description but that was lacking in the area of my questions.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QDEC - nRF52840</title><link>https://devzone.nordicsemi.com/thread/376838?ContentTypeID=1</link><pubDate>Wed, 13 Jul 2022 17:21:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a70a0e62-b62d-4657-a0b0-aa7a501b4d94</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I believe the QDEC peripheral is described in the product specification for the nRF52840?&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/qdec.html"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/qdec.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>