<?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>Read GPIO immediately after configured</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51385/read-gpio-immediately-after-configured</link><description>Tested with PCA10040 1.2.4 bare board Chosen p0.11 as it seems to connect nothing (floating) 
 I would expect the code below always prints &amp;quot;&amp;lt;info&amp;gt; Main: [11] 1 1 1 1 1&amp;quot;, no matter how many times nrf_gpio_cfg_default() is called. I did see the expected</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 26 Aug 2019 16:11:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51385/read-gpio-immediately-after-configured" /><item><title>RE: Read GPIO immediately after configured</title><link>https://devzone.nordicsemi.com/thread/206173?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2019 16:11:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62cfa9c4-3763-401c-9af2-3a683727730f</guid><dc:creator>XavierYin</dc:creator><description>&lt;p&gt;I&amp;#39;m using SES V4.20 macOS&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As far as I understand:&lt;/p&gt;
&lt;p&gt;1. SES projects should be able to work cross-platform&lt;br /&gt;2.&amp;nbsp;flashing .hex file (from full erase) should put the board into the same state&lt;br /&gt;3. should be able to see debug output through RTT after flashing the provided .hex&lt;/p&gt;
&lt;p&gt;But, of course, thank you anyway. You make me feel less alone. Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO immediately after configured</title><link>https://devzone.nordicsemi.com/thread/206172?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2019 16:04:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3c1f794-03a4-4c40-ad62-1f32db82b68a</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Time for comments from a Nordic engineer,&amp;nbsp;hopefully. I am unable to look at MAC files (I am using SES V4.20 on Windows 10), and don&amp;#39;t have any spare time just now. hex files don&amp;#39;t help as we can&amp;#39;t see debug output, I don&amp;#39;t think.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO immediately after configured</title><link>https://devzone.nordicsemi.com/thread/206165?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2019 15:28:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:692033de-dc18-46cf-9fbb-fb493ddcde34</guid><dc:creator>XavierYin</dc:creator><description>&lt;p&gt;There&amp;#39;s only&amp;nbsp;PCA10040, nothing else.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s so weird that the same project behaves differently...&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you try this binary, and could you please share your binary?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/blinky_5F00_pca10040.hex"&gt;devzone.nordicsemi.com/.../blinky_5F00_pca10040.hex&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO immediately after configured</title><link>https://devzone.nordicsemi.com/thread/206161?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2019 15:09:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd940f3d-2e52-42c6-bdaa-af5d982874e1</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;I get this, which is expected:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;&amp;lt;info&amp;gt; app: [0000000B] 1 1 1 1 1&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I ran some sanity tests, all pass:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;STATIC_ASSERT( 0 == (GPIO_PIN_CNF_DIR_Pos),   &amp;quot;Error - GPIO_PIN_CNF_DIR_Pos&amp;quot;);
STATIC_ASSERT( 1 == (GPIO_PIN_CNF_INPUT_Pos), &amp;quot;Error - GPIO_PIN_CNF_INPUT_Pos&amp;quot;);
STATIC_ASSERT( 2 == (GPIO_PIN_CNF_PULL_Pos),  &amp;quot;Error - GPIO_PIN_CNF_PULL_Pos&amp;quot;);
STATIC_ASSERT( 8 == (GPIO_PIN_CNF_DRIVE_Pos), &amp;quot;Error - GPIO_PIN_CNF_DRIVE_Pos&amp;quot;);
STATIC_ASSERT(16 == (GPIO_PIN_CNF_SENSE_Pos), &amp;quot;Error - GPIO_PIN_CNF_SENSE_Pos&amp;quot;);

STATIC_ASSERT(0x000003 ==
                   ((NRF_GPIO_PIN_DIR_OUTPUT       &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos)   |
                    (NRF_GPIO_PIN_INPUT_DISCONNECT &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos) |
                    (NRF_GPIO_PIN_NOPULL           &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos)  |
                    (NRF_GPIO_PIN_S0S1             &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos) |
                    (NRF_GPIO_PIN_NOSENSE          &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos)), &amp;quot;PIN_CFG Error&amp;quot;);
STATIC_ASSERT(0x00000 ==
                   ((NRF_GPIO_PIN_DIR_INPUT        &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos)   |
                    (NRF_GPIO_PIN_INPUT_CONNECT    &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos) |
                    (NRF_GPIO_PIN_NOPULL           &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos)  |
                    (NRF_GPIO_PIN_S0S1             &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos) |
                    (NRF_GPIO_PIN_NOSENSE          &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos)), &amp;quot;PIN_CFG Error&amp;quot;);
STATIC_ASSERT(0x00002 ==
                   ((NRF_GPIO_PIN_DIR_INPUT        &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos)   |
                    (NRF_GPIO_PIN_INPUT_DISCONNECT &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos) |
                    (NRF_GPIO_PIN_NOPULL           &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos)  |
                    (NRF_GPIO_PIN_S0S1             &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos) |
                    (NRF_GPIO_PIN_NOSENSE          &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos)), &amp;quot;PIN_CFG Error&amp;quot;);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I take it there is nothing plugged into pin 11, such as an expansion board? If that were the case, you would see a slower rise/fall time on the pin which would affect your results&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO immediately after configured</title><link>https://devzone.nordicsemi.com/thread/206137?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2019 13:48:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:daae739f-d8de-482e-93d4-e6268aff9402</guid><dc:creator>XavierYin</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/5460.blinky.zip"&gt;devzone.nordicsemi.com/.../5460.blinky.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;upload a sample SES project that repeats the problem&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/hmolesworth"&gt;hmolesworth&lt;/a&gt; would you mind to try this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO immediately after configured</title><link>https://devzone.nordicsemi.com/thread/205997?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2019 02:15:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab9752e8-7e3a-4fd3-bf75-272e7138767f</guid><dc:creator>XavierYin</dc:creator><description>&lt;p&gt;Your experiments are interesting.&lt;/p&gt;
&lt;p&gt;But with &lt;em&gt;nrf_gpio_cfg_input&lt;/em&gt; I think it alway connects input buffer with pull, isn&amp;#39;t it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO immediately after configured</title><link>https://devzone.nordicsemi.com/thread/205996?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2019 02:13:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5a74167-8a98-4c26-8c91-9e0129675376</guid><dc:creator>XavierYin</dc:creator><description>[quote userid="65515" url="~/f/nordic-q-a/51385/read-gpio-immediately-after-configured/205988"]First the latter point of a 200k pull-down resistor not holding the pin low; the internal pull-up NRF_GPIO_PIN_PULLUP is typically 13k so a 200k external resistor to Gnd will not pull down the input pin voltage far enough to fall below the &amp;#39;0&amp;#39; threshold, so reporting &amp;#39;1&amp;#39; is correct.[/quote]
&lt;p&gt;I did recognize 13k internal pull resistor so I expected the exactly the same results to be observed both on PCA10040 &amp;amp; my custom board. For discussion on Devzone I guess sticking to official EVBs will do better.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO immediately after configured</title><link>https://devzone.nordicsemi.com/thread/205988?ContentTypeID=1</link><pubDate>Sun, 25 Aug 2019 21:12:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f129b61-f950-4e25-9cc4-c2ad1a7f5751</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Out of curiosity I repeated your test and disagree with your findings. Your test does raise some useful questions, however.&lt;/p&gt;
&lt;p&gt;First the latter point of a 200k pull-down resistor not holding the pin low; the internal pull-up NRF_GPIO_PIN_PULLUP is typically 13k so a 200k external resistor to Gnd will not pull down the input pin voltage far enough to fall below the &amp;#39;0&amp;#39; threshold, so reporting &amp;#39;1&amp;#39; is correct.&lt;/p&gt;
&lt;p&gt;Using the code posted (and no setup code preceding this code) I see continuous &amp;#39;1&amp;#39; values where expected, regardless of configs. eg:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    nrf_gpio_cfg_default(GPIO_PIN_TO_TEST);
    nrf_gpio_cfg_default(GPIO_PIN_TO_TEST);
    nrf_gpio_cfg_default(GPIO_PIN_TO_TEST);
    nrf_gpio_cfg_default(GPIO_PIN_TO_TEST);
    nrf_gpio_cfg_input(GPIO_PIN_TO_TEST, NRF_GPIO_PIN_PULLUP);
    read_result[0] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[1] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[2] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[3] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[4] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    NRF_LOG_INFO(&amp;quot;[%d] %d %d %d %d %d&amp;quot;, GPIO_PIN_TO_TEST, read_result[0], read_result[1], read_result[2], read_result[3], read_result[4]);

Result:
&amp;lt;info&amp;gt; app: [11] 1 1 1 1 1
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Now the interesting part is where is the pull-up or pull-down applied; the schematic in the v1.4 datasheet implies after the input disconnect. Here I pre-charge the input pin by first pulsing it as an output, then return to an input and read in all modes:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    // Precharge pin to &amp;#39;1&amp;#39;:
    nrf_gpio_cfg(GPIO_PIN_TO_TEST, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
    nrf_gpio_pin_set(GPIO_PIN_TO_TEST);
    // Now read pin in all modes:
    nrf_gpio_cfg(GPIO_PIN_TO_TEST, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
    read_result[0] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[1] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[2] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[3] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[4] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    NRF_LOG_INFO(&amp;quot;[%d] %d %d %d %d %d&amp;quot;, GPIO_PIN_TO_TEST, read_result[0], read_result[1], read_result[2], read_result[3], read_result[4]);
    nrf_gpio_cfg(GPIO_PIN_TO_TEST, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
    read_result[0] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[1] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[2] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[3] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[4] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    NRF_LOG_INFO(&amp;quot;[%d] %d %d %d %d %d&amp;quot;, GPIO_PIN_TO_TEST, read_result[0], read_result[1], read_result[2], read_result[3], read_result[4]);
    nrf_gpio_cfg(GPIO_PIN_TO_TEST, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
    read_result[0] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[1] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[2] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[3] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[4] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    NRF_LOG_INFO(&amp;quot;[%d] %d %d %d %d %d&amp;quot;, GPIO_PIN_TO_TEST, read_result[0], read_result[1], read_result[2], read_result[3], read_result[4]);

    nrf_gpio_cfg(GPIO_PIN_TO_TEST, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_CONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
    read_result[0] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[1] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[2] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[3] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[4] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    NRF_LOG_INFO(&amp;quot;[%d] %d %d %d %d %d&amp;quot;, GPIO_PIN_TO_TEST, read_result[0], read_result[1], read_result[2], read_result[3], read_result[4]);
    nrf_gpio_cfg(GPIO_PIN_TO_TEST, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_CONNECT, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
    read_result[0] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[1] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[2] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[3] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[4] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    NRF_LOG_INFO(&amp;quot;[%d] %d %d %d %d %d&amp;quot;, GPIO_PIN_TO_TEST, read_result[0], read_result[1], read_result[2], read_result[3], read_result[4]);
    nrf_gpio_cfg(GPIO_PIN_TO_TEST, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_CONNECT, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
    read_result[0] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[1] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[2] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[3] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    read_result[4] = nrf_gpio_pin_read(GPIO_PIN_TO_TEST);
    NRF_LOG_INFO(&amp;quot;[%d] %d %d %d %d %d&amp;quot;, GPIO_PIN_TO_TEST, read_result[0], read_result[1], read_result[2], read_result[3], read_result[4]);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The results are as expected but interesting:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;&amp;lt;info&amp;gt; app: [11] 1 1 1 1 1
&amp;lt;info&amp;gt; app: [11] 0 0 0 0 0
&amp;lt;info&amp;gt; app: [11] 0 0 0 0 0
&amp;lt;info&amp;gt; app: [11] 0 0 0 0 0
&amp;lt;info&amp;gt; app: [11] 0 0 0 0 0
&amp;lt;info&amp;gt; app: [11] 1 1 1 1 1
&amp;lt;info&amp;gt; app: [11] 0 0 0 0 0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;#39;1&amp;#39; when reading back the output, but when reading back as inputs the only time &amp;#39;1&amp;#39; is read is when the input is connected and the pull-up is selected. With pull-up selected but input disconnected we get a &amp;#39;0&amp;#39;, which means the pull-up/pull-down in the schematic is incorrectly shown as downwind (closer to the cpu) than the input connect switch.&lt;/p&gt;
&lt;p&gt;Pre-charging the pin with &amp;#39;0&amp;#39; gives the same results.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;&amp;lt;info&amp;gt; app: [11] 1 1 1 1 1
&amp;lt;info&amp;gt; app: [11] 0 0 0 0 0
&amp;lt;info&amp;gt; app: [11] 0 0 0 0 0
&amp;lt;info&amp;gt; app: [11] 0 0 0 0 0
&amp;lt;info&amp;gt; app: [11] 0 0 0 0 0
&amp;lt;info&amp;gt; app: [11] 1 1 1 1 1
&amp;lt;info&amp;gt; app: [11] 0 0 0 0 0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The reason &amp;#39;0&amp;#39; is read when input is disconnected regardless of pull-up or pull-down is given by the Feed-through issue handling:&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;em&gt;When a pin is configured as digital input, care has been taken in the nRF52832 design&amp;nbsp;to minimize increased current consumption when the input voltage is between VIL and VIH. However,&amp;nbsp;it is a good practice to ensure that the external circuitry does not drive that pin to levels between VIL&amp;nbsp;and VIH for a long period of time&lt;/em&gt;.&amp;quot;&lt;/p&gt;
&lt;p&gt;Feed-through is unwanted increase in power by current Ist travelling between Vdd and Gnd not through the input pin but through the input FETs when the input voltage lies within the vanishingly small window where both FETs are slightly turned on:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/CMOS_5F00_Inputs_5F00_Shoot_2D00_through.png_2D00_1230x0.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>