<?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>How to use TRACE pins as GPIO</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62892/how-to-use-trace-pins-as-gpio</link><description>We are developing a board based on nRF52840. One of the pins we would like to use as GPIO is P1.09. It is configured as GPIO (the same configuration as P0.12), but the output does not get set to 1 (the P0.12 does get set to 1 using identical code). 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Jun 2020 20:37:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62892/how-to-use-trace-pins-as-gpio" /><item><title>RE: How to use TRACE pins as GPIO</title><link>https://devzone.nordicsemi.com/thread/256546?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 20:37:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:581613bd-a44e-424e-ae1e-2d0b2dca33e9</guid><dc:creator>Matevz B</dc:creator><description>&lt;p&gt;Thank you both TurboJ and hmolesworth for help and solving this issue.&lt;/p&gt;
&lt;p&gt;I initially developed the application on nRF52 DK with nRF52832 where there was only P0. I was not aware of neat Nordic function, therefore I wrote my own. Switching to nRF52840 on custom PCB, use of P1 was more convenient, but obviously writing out of NRF_GPIO does no good.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I would only like to add a few things which I &amp;quot;figured out&amp;quot; (learnt actually) solving this issue. These may be useful for other newbies.&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Nordic GPIO functions are defined in nrf_gpio.h.&lt;/li&gt;
&lt;li&gt;There is also a function:&lt;br /&gt;__STATIC_INLINE void &lt;strong&gt;nrf_gpio_pin_write&lt;/strong&gt;(uint32_t pin_number, uint32_t value);&lt;br /&gt;which can be used to &amp;quot;write&amp;quot; 0 and 1 (anything else actually).&lt;/li&gt;
&lt;li&gt;NRF_CLOCK register is defined (among others) in nrf52840.h (or other corresponding file).&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use TRACE pins as GPIO</title><link>https://devzone.nordicsemi.com/thread/256293?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 02:00:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bdf1d2a1-6dac-4789-9f0f-8701d20c0bf8</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Confusion between P0 and P1, easily done. NRF_GPIO refers to P0; better to either use all Nordic definitions or don&amp;#39;t use any, but here they are mixed. Replace NRF_GPIO with NRF_P1 in this code, or just use the Nordic functions and not the NrF_GPIO and NRF_P1 registers directly. The function is (to set to &amp;#39;1&amp;#39;)&amp;nbsp;&lt;em&gt;nrf_gpio_pin_set(pin)&lt;/em&gt; and so on.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use TRACE pins as GPIO</title><link>https://devzone.nordicsemi.com/thread/256290?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 00:24:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68404219-d6ab-42bc-8b31-5088fa0d5b97</guid><dc:creator>Matevz B</dc:creator><description>&lt;p&gt;Turbo J thank you.&lt;/p&gt;
&lt;p&gt;It is set correct:&lt;br /&gt;NRF_CLOCK-&amp;gt;TRACECONFIG: 0x0&lt;/p&gt;
&lt;p&gt;I added this:&amp;nbsp;&lt;br /&gt;__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;NRF_CLOCK-&amp;gt;TRACECONFIG: 0x%x\n&amp;quot;, NRF_CLOCK-&amp;gt;TRACECONFIG);&lt;/p&gt;
&lt;p&gt;Which resutls in: &lt;br /&gt;main.c,&amp;nbsp; 583, NRF_CLOCK-&amp;gt;TRACECONFIG: 0x0&lt;/p&gt;
&lt;p&gt;This is pin definition:&lt;br /&gt;#define PIN_MOTOR_NEG&amp;nbsp; &amp;nbsp; NRF_GPIO_PIN_MAP(1,9)&lt;/p&gt;
&lt;p&gt;This is pin configuration:&lt;br /&gt;#define PIN_MOTOR_CONFIG ((GPIO_PIN_CNF_SENSE_Disabled &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos) | \&lt;br /&gt; (GPIO_PIN_CNF_DRIVE_S0S1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos) | \&lt;br /&gt; (GPIO_PIN_CNF_PULL_Disabled &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos) | \&lt;br /&gt; (GPIO_PIN_CNF_INPUT_Disconnect &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos) | \&lt;br /&gt; (GPIO_PIN_CNF_DIR_Output &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos))&lt;/p&gt;
&lt;p&gt;This is pin initialization:&lt;br /&gt;gpio_pin_init(PIN_MOTOR_NEG, PIN_MOTOR_CONFIG);&lt;/p&gt;
&lt;p&gt;The function:&lt;br /&gt;void gpio_pin_init(uint32_t pin, uint32_t configuration)&lt;br /&gt;{&lt;br /&gt; NRF_GPIO-&amp;gt;PIN_CNF[pin] = configuration;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;Setting pin:&lt;br /&gt;gpio_pin_set(PIN_MOTOR_NEG, 1);&lt;/p&gt;
&lt;p&gt;Function:&lt;br /&gt;void gpio_pin_set(uint32_t pin, uint8_t value)&lt;br /&gt;{&lt;br /&gt; if (value)&lt;br /&gt; {&lt;br /&gt; NRF_GPIO-&amp;gt;OUTSET = 1UL &amp;lt;&amp;lt; pin;&lt;br /&gt;}&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; NRF_GPIO-&amp;gt;OUTCLR = 1UL &amp;lt;&amp;lt; pin;&lt;br /&gt;}&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;And reading the pin immediatelly after setting returns 0.&lt;/p&gt;
&lt;p&gt;The positive pin, P0.12 works fine with the same code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use TRACE pins as GPIO</title><link>https://devzone.nordicsemi.com/thread/256289?ContentTypeID=1</link><pubDate>Mon, 22 Jun 2020 23:51:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe896d01-e2be-43a3-a037-452e9aacd10c</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Check the TRACECONFIG register (in CLOCK), e.g. with a debugger. Its contents shows whether the pins are GPIO or trace mode.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>