<?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>Reading GPIO_IDR assembly</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/34646/reading-gpio_idr-assembly</link><description> 
Hello, I am using a discovery board with an STM32l152. The user
push button is ported to PA0. I need to read from the IDR bit on the
GPIOA when the button is pushed. I read that it can only be accessed
via word only. I have already set up the moder</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Reading GPIO_IDR assembly</title><link>https://community.arm.com/thread/129045?ContentTypeID=1</link><pubDate>Mon, 21 Sep 2015 00:17:35 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a4cc8ea1-5149-475a-988a-41cfaca09851</guid><dc:creator>Harib Suntar</dc:creator><description>&lt;p&gt;&lt;p&gt;
And your C line&lt;/p&gt;

&lt;pre&gt;
   if((GPIOA-IDR &amp;amp; 0x1) == 1) turn on LED
&lt;/pre&gt;

&lt;p&gt;
can be something like:&lt;/p&gt;

&lt;pre&gt;
        LDR r0, GPIOA_ADDR

        LDR  R1,[R0]
        TST  R1,#0x00000001
        BEQ  SkipIt
        ;TURN ON LED

SkipIt: ;Carry on
&lt;/pre&gt;

&lt;p&gt;
ARM assembler isn&amp;#39;t the easiest but it can be good fun and not
many programmers bother with it because they think they can do
everything in C and don&amp;#39;t think they need to understand the low level
stuff.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading GPIO_IDR assembly</title><link>https://community.arm.com/thread/117858?ContentTypeID=1</link><pubDate>Sun, 20 Sep 2015 23:39:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:13ff9766-67c3-444c-9371-acc858934257</guid><dc:creator>Harib Suntar</dc:creator><description>&lt;p&gt;&lt;pre&gt;
  LDR r0, =0x40000000 ;PERIPH_BASE
   ADD r0, #0x20000      ;AHBPERIPH_BASE
   ADD r0, #0x0400               ;GPIOA_BASE
   ADD r0, #0x10
&lt;/pre&gt;

&lt;p&gt;
Can be a single line&lt;/p&gt;

&lt;pre&gt;
  LDR r0, =0x40000000+0x20000+0x0400+0x10 ;PERIPH_BASE+AHBPERIPH_BASE+GPIOA_BASE
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading GPIO_IDR assembly</title><link>https://community.arm.com/thread/108446?ContentTypeID=1</link><pubDate>Sun, 20 Sep 2015 14:45:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:53b3ae30-2129-4caa-9e6c-e6ef55f8658e</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
If you have a commercial license, you can ask the compiler to
produce a list file.&lt;/p&gt;

&lt;p&gt;
With the demo version, you&amp;#39;ll have to settle for stepping in the
debugger.&lt;/p&gt;

&lt;p&gt;
If you are learning assembler, then one of the things you need to
learn quickly is how to assign an arbitrary pointer - or integer - to
a register. If the core can&amp;#39;t perform a 32-bit immediate load, then
you&amp;#39;ll have to consider doing an indirect load, or combine two 16-bit
loads.&lt;/p&gt;

&lt;p&gt;
Often, it&amp;#39;s a good idea to load a base pointer with specific
enough address that the processor supports the relative offset
directly when doing the following operations. So you basically ends
up with something like (in C)&lt;/p&gt;

&lt;pre&gt;
port_1-&amp;gt;reg1 = xx;
port_1-&amp;gt;reg2 = yy;
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
or in array notation&lt;/p&gt;

&lt;pre&gt;
port_1[offset_reg1] = xx;
port_1[offset_reg2] = yy;
&lt;/pre&gt;

&lt;p&gt;
Remember that the assembler can add together multiple constants at
build time, so you don&amp;#39;t need your processor to add the numbers at
run-time.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading GPIO_IDR assembly</title><link>https://community.arm.com/thread/82815?ContentTypeID=1</link><pubDate>Sun, 20 Sep 2015 14:04:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:03295078-554a-46ed-9812-10d6c0e883e3</guid><dc:creator>camilo ochoa</dc:creator><description>&lt;p&gt;&lt;p&gt;
There are more efficient ways to do everything but since I am just
learning assembly, this will do for now. When you say &amp;quot;code that the
Keil compiler generates&amp;quot; do you mean go into debug mode and look at
disassembly?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading GPIO_IDR assembly</title><link>https://community.arm.com/thread/69363?ContentTypeID=1</link><pubDate>Sun, 20 Sep 2015 08:59:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4e672099-a40c-4c9a-a529-9a5523169186</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;pre&gt;
  LDR r0, =0x40000000 ;PERIPH_BASE
   ADD r0, #0x20000      ;AHBPERIPH_BASE
   ADD r0, #0x0400               ;GPIOA_BASE
   ADD r0, #0x10
&lt;/pre&gt;

&lt;p&gt;
Note that there are way more efficient ways to get the address of
the register.&lt;/p&gt;

&lt;p&gt;
Maybe you should spend some time looking at the code that the Keil
compiler generates, with the processor instruction set document as
cross-reference.&lt;/p&gt;

&lt;p&gt;
The documentation tells what an instruction does, while the
compiler output will give an indication of how you use the
instructions practically.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>