<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/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/"><channel><title>Simple GPIO read not working -</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/30422/simple-gpio-read-not-working--</link><description> 
Firstly, I&amp;#39;n fairly new Keil, and am &amp;quot;upgrading from 8-bit
PIC&amp;#39;s&amp;quot; 

 
I&amp;#39;m trying to read some data from an ADC. 

 
Not working so I wrote a simple program that reads the input pin
status. 

 
To my surprise it doesn&amp;#39;t seem to pay any attention to reading</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Simple GPIO read not working -</title><link>https://community.arm.com/thread/132189?ContentTypeID=1</link><pubDate>Sat, 11 May 2013 09:15:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d2714e73-9602-4e06-a845-7f8ba77be5f7</guid><dc:creator>Rob Ashworth</dc:creator><description>&lt;p&gt;&lt;p&gt;
problem sorted.&lt;/p&gt;

&lt;p&gt;
As perhaps hinted at I was miss-reading the hardware schematic -
so what was labeled D0 was in fact portA bit3 not portD bit0!!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple GPIO read not working -</title><link>https://community.arm.com/thread/107101?ContentTypeID=1</link><pubDate>Thu, 09 May 2013 22:51:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fa55fab5-c76c-44dc-9933-20113197211d</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
ST&amp;#39;s examples for the STM32 Standard Peripheral Library? Or the
Discovery boards?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple GPIO read not working -</title><link>https://community.arm.com/thread/107095?ContentTypeID=1</link><pubDate>Thu, 09 May 2013 17:09:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:22d215bb-f5b7-411f-8fb1-f6ce42f24d23</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
I don&amp;#39;t use that library so I don&amp;#39;t know the specifics of how it
works.&lt;/p&gt;

&lt;p&gt;
But if you take a structure and assign three fields before
initializing the first port.&lt;/p&gt;

&lt;p&gt;
You then reuse the same structure and assign only two fields
before initializing the second port.&lt;/p&gt;

&lt;p&gt;
Isn&amp;#39;t it likely then that the third field - that you didn&amp;#39;t make
any assign to - will still say GPIO_Mode_Out_PP, making the pin you
expected to use as an input become an output?&lt;/p&gt;

&lt;p&gt;
You based your code on an example? But didn&amp;#39;t you locate the
reference for the library functionality? Especially after your
program didn&amp;#39;t work? Does the library reference claim that every call
to GPIO_Init() will reset all fields of that structure to a neutral
state? Because your code is written as if it did.&lt;/p&gt;

&lt;p&gt;
Never ever use code you find on the net without understanding
every single line of it. And that would include locating the
documentation for library functions called, unless you already know
the specifics of the used library functions (like strcpy(), etc).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple GPIO read not working -</title><link>https://community.arm.com/thread/81220?ContentTypeID=1</link><pubDate>Thu, 09 May 2013 15:31:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:257194b0-441a-47db-a83f-c5f5cbb12718</guid><dc:creator>Rob Ashworth</dc:creator><description>&lt;p&gt;&lt;p&gt;
Are you able to show me how it should be done. I took this from an
example from the Keillor website, so assumed it would be
correct....I&amp;#39;m not sure I know what you mean by clearing the
structure?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple GPIO read not working -</title><link>https://community.arm.com/thread/68281?ContentTypeID=1</link><pubDate>Thu, 09 May 2013 14:47:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5b8df444-9439-4987-b471-3b0832334a37</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Reuse of data structure:&lt;/p&gt;

&lt;pre&gt;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_1 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;  &amp;lt;== here you request your LED pins to be output
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_10MHz;
GPIO_Init(GPIOA,&amp;amp;GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
***
*** where did the structure get cleared? will you not make GPIOD.4 an output too?
***
GPIO_Init(GPIOD,&amp;amp;GPIO_InitStructure);
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>