<?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>Proggram GPIOTE using registers</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38557/proggram-gpiote-using-registers</link><description>Hi everyone, 
 I&amp;#39;m learning about proggram the nRF52840 dongle and I tried to code an interruption. Press the SW2 to turn on a LED 
 
 So, looking at this code, where did I fail? 
 Thanks for helping and best regards.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 19 Sep 2018 18:11:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38557/proggram-gpiote-using-registers" /><item><title>RE: Proggram GPIOTE using registers</title><link>https://devzone.nordicsemi.com/thread/149508?ContentTypeID=1</link><pubDate>Wed, 19 Sep 2018 18:11:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:804bf4b8-666a-4c97-813c-ad6b83f012a8</guid><dc:creator>mcls</dc:creator><description>&lt;p&gt;This code is what I made to turn up the LED. With the changes you suggested me it worked and using the &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52840.ps%2Fppi.html"&gt;PPI&lt;/a&gt; is so much easier. Thank you very much Sir&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;


#define MODE 0
#define PSEL 8
#define PORT 13
#define POLARITY 16
#define OUTINIT 20
#define PULL 2
#define DIR 0
#define INPUT 1
#define PULL 2
#define DRIVE 8
#define SENSE 16

int main(void) {

  //PIN SETTINGS
  //Boton
  NRF_P1-&amp;gt;PIN_CNF[6] = (0x00 &amp;lt;&amp;lt; DIR) | (0x03 &amp;lt;&amp;lt; PULL) | (0x00 &amp;lt;&amp;lt; DRIVE) | (0x00 &amp;lt;&amp;lt; SENSE);
//  
//  //LED
//  //NRF_P0-&amp;gt;PIN_CNF[8] = (0x01 &amp;lt;&amp;lt; 0x00);
//
//  //BOTON config
  NRF_GPIOTE-&amp;gt;CONFIG[0] = (0x01 &amp;lt;&amp;lt; MODE) | (0x06 &amp;lt;&amp;lt; PSEL) | (0x01 &amp;lt;&amp;lt; PORT) | (0x03 &amp;lt;&amp;lt; POLARITY);
//  
//  //LED config
  NRF_GPIOTE-&amp;gt;CONFIG[1] = (0x03 &amp;lt;&amp;lt; MODE) | (0x08 &amp;lt;&amp;lt; PSEL) | (0x00 &amp;lt;&amp;lt; PORT) | (0x03 &amp;lt;&amp;lt; POLARITY) | (0x01 &amp;lt;&amp;lt; OUTINIT);
// 
//  //Enable Tasks &amp;amp; Events
  NRF_GPIOTE-&amp;gt;INTENSET = (0x01 &amp;lt;&amp;lt; 0x00) | (0x01 &amp;lt;&amp;lt; 0x01);
//  
//  //RESET EVENTS
  NRF_GPIOTE-&amp;gt;EVENTS_IN[0] = 0;  
//
//  //PPI
  NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;EVENTS_IN[0];
  NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_OUT[1];
  NRF_PPI-&amp;gt;CHEN = (0x01 &amp;lt;&amp;lt; 0x00);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proggram GPIOTE using registers</title><link>https://devzone.nordicsemi.com/thread/149502?ContentTypeID=1</link><pubDate>Wed, 19 Sep 2018 17:07:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5abd75e2-6915-4f47-9379-785c3dd87a57</guid><dc:creator>mcls</dc:creator><description>&lt;p&gt;Thanks a lot Simon. God bless you. I will try PPI.&lt;/p&gt;
&lt;p&gt;Best regards, Pablo.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proggram GPIOTE using registers</title><link>https://devzone.nordicsemi.com/thread/149307?ContentTypeID=1</link><pubDate>Tue, 18 Sep 2018 16:05:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:202a28ae-c555-4b72-bec0-c6a058d80419</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I have looked at your code and managed to get it work with the following changes&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Skipped the code for setting the LED as output, it will be taken care of during the GPIOTE configuration&lt;/li&gt;
&lt;li&gt;Did not set the SENSE field (However, you used a value 0x16, which is 22 in decimal, and will not set the SENSE field)&lt;/li&gt;
&lt;li&gt;When configuring button 1, I used port 0 instead of port 1&lt;/li&gt;
&lt;li&gt;No point of running&amp;nbsp;NRF_P0-&amp;gt;OUT = (0x01 &amp;lt;&amp;lt; 0x08), since the value assigned to OUTINIT will overwite it&lt;/li&gt;
&lt;li&gt;Better to use BUTTON_1 and LED_1, if using pca10059 examples it will be defined to appropriate pins to work with the nRF52840 dongle&lt;/li&gt;
&lt;li&gt;When configuring button 1 through PIN_CNF, I used pullup instead of pulldown&lt;/li&gt;
&lt;li&gt;Added&amp;nbsp;&lt;span style="font-weight:400;"&gt;NRF_GPIOTE-&amp;gt;EVENTS_IN[0] = 0; in if condition&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Changed&amp;nbsp;&lt;span style="font-weight:400;"&gt;TASK_SET[1] to TASKS_OUT[1] = 1&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;Changed polarity from 0 to 3 when configuring the LED as a GPIOTE event&lt;/span&gt;&lt;span style="font-weight:400;"&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;If these bulletpoints are too messy, take a look at the code:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-ef7bd2ae5e73451e8d895af10fc2a154/GPIOTE_5F00_DONGLE.zip"&gt;devzone.nordicsemi.com/.../GPIOTE_5F00_DONGLE.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For the nRF52840 dongle, use the example in pca10059/mbr, and the hex file is located in&amp;nbsp;&lt;span&gt;pca10059/mbr/Output/Release/Exe&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;However, I would advice you to use&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52840.ps%2Fppi.html"&gt;PPI&lt;/a&gt;, which will connect tasks to events and you can&amp;nbsp;make peripherals interact with each other without using the CPU. Using a higher abstraction layer, like&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.2.0%2Fgroup__nrf__gpiote__hal.html"&gt;GPIOTE HAL&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.2.0%2Fgroup__nrf__drv__gpiote.html"&gt;GPIOTE driver&lt;/a&gt;&amp;nbsp;will also make it easier.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Best regards Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proggram GPIOTE using registers</title><link>https://devzone.nordicsemi.com/thread/149303?ContentTypeID=1</link><pubDate>Tue, 18 Sep 2018 16:04:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:652018c3-577f-4ac5-b50e-947e98c4d045</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I have looked at your code and managed to get it work with the following changes&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Skipped the code for setting the LED as output, it will be taken care of during the GPIOTE configuration&lt;/li&gt;
&lt;li&gt;Did not set the SENSE field (However, you used a value 0x16, which is 22 in decimal, and will not set the SENSE field)&lt;/li&gt;
&lt;li&gt;When configuring button 1 I used port 0 instead of port 1&lt;/li&gt;
&lt;li&gt;No point of running&amp;nbsp;NRF_P0-&amp;gt;OUT = (0x01 &amp;lt;&amp;lt; 0x08), since the value assigned to OUTINIT will overwite it&lt;/li&gt;
&lt;li&gt;Better to use BUTTON_1 and LED_1, if using pca10059 examples it will be defined to appropriate pins to work with the nRF52840 dongle&lt;/li&gt;
&lt;li&gt;When configuring button 1 through PIN_CNF I used pulldown instead of pullup&lt;/li&gt;
&lt;li&gt;Added&amp;nbsp;&lt;span style="font-weight:400;"&gt;NRF_GPIOTE-&amp;gt;EVENTS_IN[0] = 0; in if condition&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Changed&amp;nbsp;&lt;span style="font-weight:400;"&gt;TASK_SET[1] to TASKS_OUT[1] = 1&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;Changed polarity from 0 to 3 when configuring the LED as a GPIOTE event&lt;/span&gt;&lt;span style="font-weight:400;"&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;If these bulletpoints are too messy, take a look at the code:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-ef7bd2ae5e73451e8d895af10fc2a154/GPIOTE_5F00_DONGLE.zip"&gt;devzone.nordicsemi.com/.../GPIOTE_5F00_DONGLE.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For the nRF52840 use the example in pca10059/mbr, and the hex file is located in&amp;nbsp;&lt;span&gt;pca10059/mbr/Output/Release/Exe&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;However I would advice you to use&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52840.ps%2Fppi.html"&gt;PPI&lt;/a&gt;, which will connect tasks to events and you can&amp;nbsp;make peripherals interact with each other without using the CPU. Using a higher abstraction layer, like&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.2.0%2Fgroup__nrf__gpiote__hal.html"&gt;GPIOTE HAL&lt;/a&gt;&amp;nbsp;will make it easier.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Best regards Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>