<?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>GPIO act incorrectly when building with GCC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20969/gpio-act-incorrectly-when-building-with-gcc</link><description>Hi, 
 I connected 74CH595 shift registers to nRF52DK board. When I built and upload my code with Keil everything works just fine, but if I compliled it with GCC and upload with nrfjprog, the 74CH595 cannot act properly. I need to combine the code with</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 30 Mar 2017 14:06:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20969/gpio-act-incorrectly-when-building-with-gcc" /><item><title>RE: GPIO act incorrectly when building with GCC</title><link>https://devzone.nordicsemi.com/thread/81950?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2017 14:06:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c584367-f90e-478c-9afa-39f5c4cd22ff</guid><dc:creator>Quark</dc:creator><description>&lt;p&gt;Tried Os option, but even set optimization for size does not make it slower, I still need to add the delay to produce correct clock sequence. FYR&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO act incorrectly when building with GCC</title><link>https://devzone.nordicsemi.com/thread/81948?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2017 13:59:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fb12459-1839-4b12-893f-9bed00fd7bc4</guid><dc:creator>Quark</dc:creator><description>&lt;p&gt;OK, I will try it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO act incorrectly when building with GCC</title><link>https://devzone.nordicsemi.com/thread/81947?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2017 13:48:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9731c7ae-bcc8-41f1-ac6e-207298d9351f</guid><dc:creator>Radoslaw Koppel</dc:creator><description>&lt;p&gt;In our examples GCC is optimised using O3 level that intuitively relates to Level 3 optimisation in Keil. (Whisper:) Use Os instead and compare the compiled codes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO act incorrectly when building with GCC</title><link>https://devzone.nordicsemi.com/thread/81949?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2017 13:34:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c942a8b0-080e-4a5b-a8d9-8dbbfce154b9</guid><dc:creator>Quark</dc:creator><description>&lt;p&gt;Great, myth busted, thanks for the answer!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO act incorrectly when building with GCC</title><link>https://devzone.nordicsemi.com/thread/81946?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2017 13:00:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0a4913f-0236-4d8a-a8dd-a82b534e12a1</guid><dc:creator>Radoslaw Koppel</dc:creator><description>&lt;p&gt;Yes - We was also experiencing this issue writting the libraries. GCC is much more efficient with inlining the code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO act incorrectly when building with GCC</title><link>https://devzone.nordicsemi.com/thread/81945?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2017 12:40:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de142203-aa93-421a-871d-fdddb3ef766b</guid><dc:creator>Quark</dc:creator><description>&lt;p&gt;I found I can fix the problem by adding some delay (1us will be fine) as below&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  for (int i = 0; i &amp;lt; DOUT_LINES; i++) {
        nrf_gpio_pin_write(DS, i == line);
		nrf_delay_us(1);
		nrf_gpio_pin_write(SHCP, HIGH);
		nrf_delay_us(1);
		nrf_gpio_pin_write(SHCP, LOW);
		nrf_delay_us(1);
  }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But why code compiled with Keil does not need this delay? Does it mean GCC compiled code is running more efficiently (faster) than compiled by Keil?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>