<?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>Timer, GPIOTE, PPI problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40048/timer-gpiote-ppi-problem</link><description>I&amp;#39;m using an nrf52832 development board and am trying to implement a simple toggling of an output pin using a timer and PPI. Below is the code I’m using; however, the pin doesn’t toggle but stays high. Any help appreciated. 
 #define PIN 30 
 NRF_TIMER1</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 06 Nov 2018 10:17:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40048/timer-gpiote-ppi-problem" /><item><title>RE: Timer, GPIOTE, PPI problem</title><link>https://devzone.nordicsemi.com/thread/156107?ContentTypeID=1</link><pubDate>Tue, 06 Nov 2018 10:17:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:003d952c-577a-4dfd-89b4-c675f236a8cc</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply.&lt;/p&gt;
&lt;p&gt;I did some testing. Modified your code to use the macros instead of just numbers, so that they are a bit more easy to read. I am having difficulties reproducing what you are seeing.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can you test the attached main.c file? It is just modified from the project that I attached earlier.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-3896a32bd8594fef92f6e07dd3fbfbbe/main.c"&gt;devzone.nordicsemi.com/.../main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer, GPIOTE, PPI problem</title><link>https://devzone.nordicsemi.com/thread/155622?ContentTypeID=1</link><pubDate>Thu, 01 Nov 2018 16:09:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:231292d3-26ad-4051-a8c4-5da82c7018f5</guid><dc:creator>Marc</dc:creator><description>&lt;p&gt;Edvin,&lt;/p&gt;
&lt;p&gt;The difference between my implementation and yours is that you have two timer compare events for each output pin. One for driving the pin high the other for driving it low.&lt;/p&gt;
&lt;p&gt;My understanding of the GPIOTE-&amp;gt;CONFIG[n] toggle polarity setting was that the pin is toggled (driven high if low or low if high) with TASK_OUT[n]. That&amp;#39;s why I have&amp;nbsp;&lt;/p&gt;
&lt;p&gt;NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t)&amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0];&lt;/p&gt;
&lt;p&gt;NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;TASKS_OUT[0];&lt;/p&gt;
&lt;div class="page" title="Page 159"&gt;
&lt;div class="section"&gt;
&lt;div class="layoutArea"&gt;
&lt;div class="column"&gt;
&lt;p&gt;However, it doesn&amp;#39;t appear that the toggle mode works in this way. The TASKS_OUT[0]&amp;nbsp;task triggered by the EVENTS_COMPARE[0] event doesn&amp;#39;t toggle the pin. Can you explain?&lt;/p&gt;
&lt;p&gt;The following modification to my code based on yours works:&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_TIMER1-&amp;gt;MODE = 0;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;//timer mode&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_TIMER1-&amp;gt;BITMODE = 0;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;//16 bit timer width&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_TIMER1-&amp;gt;PRESCALER = 4;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;//16MHz / 2^4 = 1MHz&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_TIMER1-&amp;gt;SHORTS = 2;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;//timer cleared at CC[1]&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_TIMER1-&amp;gt;CC[0] = 1000;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;//.001 secs&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_TIMER1-&amp;gt;CC[1] = 2000;&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;//.002 secs&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_GPIOTE-&amp;gt;CONFIG[0] = (3 | (PIN &amp;lt;&amp;lt; 8) | (3 &amp;lt;&amp;lt; 16) | (1 &amp;lt;&amp;lt; 20));&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;//task mode, PIN selected, toggle,&amp;nbsp;PIN high initially&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;//Configure PPI channels 0 and 1 to drive PIN low on every Timer 1 COMPARE[0] match and high on every Timer 1 COMPARE[1] match&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t)&amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0];&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;TASKS_CLR[0];&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_PPI-&amp;gt;CH[1].EEP = (uint32_t)&amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[1];&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_PPI-&amp;gt;CH[1].TEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;TASKS_SET[0];&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_PPI-&amp;gt;CHENSET = (1 &amp;lt;&amp;lt; 1) | (1 &amp;lt;&amp;lt; 0);&lt;span class="Apple-converted-space"&gt;&amp;nbsp; &lt;/span&gt;//enable PPI channel 0&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;NRF_TIMER1-&amp;gt;TASKS_START = 1;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer, GPIOTE, PPI problem</title><link>https://devzone.nordicsemi.com/thread/155420?ContentTypeID=1</link><pubDate>Wed, 31 Oct 2018 17:13:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcf9c7db-d9d7-463d-8789-e20ea727fd6e</guid><dc:creator>Marc</dc:creator><description>&lt;p&gt;Your code works. I&amp;#39;ll compare it to mine.&lt;/p&gt;
&lt;p&gt;Thanks for the help&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer, GPIOTE, PPI problem</title><link>https://devzone.nordicsemi.com/thread/155416?ContentTypeID=1</link><pubDate>Wed, 31 Oct 2018 16:35:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de5da1ef-bced-4cbe-9f31-7586c469b8da</guid><dc:creator>Marc</dc:creator><description>&lt;p&gt;Thanks, Edvin. I&amp;#39;m looking at it now and will let you know.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer, GPIOTE, PPI problem</title><link>https://devzone.nordicsemi.com/thread/155411?ContentTypeID=1</link><pubDate>Wed, 31 Oct 2018 16:21:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d129d037-8441-453b-9dce-57c50e9506b4</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Just popping by in the end of the day, so I haven&amp;#39;t tested your implementation, but I have a similar project that I tested earlier.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-3896a32bd8594fef92f6e07dd3fbfbbe/ppi_5F00_double_5F00_channel_5F00_pwm.zip"&gt;devzone.nordicsemi.com/.../ppi_5F00_double_5F00_channel_5F00_pwm.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It was written in SDK14.0.0, but if you want it in another SDK, just use the main.c file in your project.&lt;/p&gt;
&lt;p&gt;Compare the implementation with yours, and let me know if you are stuck.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>