<?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>Mixing c &amp;amp; assembly in Keil IDE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9861/mixing-c-assembly-in-keil-ide</link><description>Dear Nordic,
Whats wrong with the below code. It works well in RFduino but when I try to port the same code in Keil environment.Its not working throwing error as
1.identifier &amp;quot;asm is undefined
2. expected a &amp;quot;;&amp;quot;
code below 
 void mixC_and_Assembly</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Oct 2015 01:47:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9861/mixing-c-assembly-in-keil-ide" /><item><title>RE: Mixing c &amp; assembly in Keil IDE</title><link>https://devzone.nordicsemi.com/thread/36595?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2015 01:47:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64e4ffb0-5fe5-409a-b928-1d16c646a5e2</guid><dc:creator>lakshman</dc:creator><description>&lt;p&gt;Hi Hung Bui,
Thanks for your response. Yes I am not using any interrupt in application except UART. But my assumption is once I get the value from UART I will set the GPIO.So timing for set &amp;amp; clear is less than UART( User send the data by pressing the button).
moreover I use 	 __disable_irq(); GPIO on/off  __enable_irq(); in my code.
Thanks and Regards
Lakshman.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mixing c &amp; assembly in Keil IDE</title><link>https://devzone.nordicsemi.com/thread/36594?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 11:21:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:005a2947-c228-4262-b367-5b765e8387db</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Lakshman,&lt;/p&gt;
&lt;p&gt;You are correct, if you want to set and clear multiple pins at the same time then OUTSET and OUTCLR won&amp;#39;t do the task. If you have to call 2 instruction, the delay will be 62.5 ns.&lt;/p&gt;
&lt;p&gt;The issue with OUT register, that I am afraid of is that to be able to not affect other pins, we need to read the OUT register before set it. The value of OUT register can be changed between when we read and we set (by an interrupt handler for example). But if you don&amp;#39;t have interrupt that change out register then you should be fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mixing c &amp; assembly in Keil IDE</title><link>https://devzone.nordicsemi.com/thread/36593?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 01:53:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:486558fc-e0ec-49cc-85ce-8aeb23a91efe</guid><dc:creator>lakshman</dc:creator><description>&lt;p&gt;Hi HungBui,
Agreed. But I need to use NRF_GPIO-&amp;gt;OUTSET  to set and NRF_GPIO-&amp;gt;OUTCLR to clear the multiple pin.
but incase of NRF_GPIO-&amp;gt;OUT I can set &amp;amp; clear multiple pins at the same time.
for example : pin2 set, pin 3 set, pin 4 clear, pint 5 set in one cycle
pin2 clear, pin 3 set, pin4 set , pin 5 clear in another cycle
please correct me if I am wrong.&lt;/p&gt;
&lt;p&gt;Thanks and Regards
Lakshman,PMP,PMI-RMP&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mixing c &amp; assembly in Keil IDE</title><link>https://devzone.nordicsemi.com/thread/36592?ContentTypeID=1</link><pubDate>Mon, 26 Oct 2015 10:22:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4a8dd60-6469-4620-b78e-056a96f9d5f7</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Lakshman,&lt;/p&gt;
&lt;p&gt;Actually using NRF_GPIO-&amp;gt;OUTSET you can set multiple pins not just 1 pin. They will be set at the same cycle. Same applied for NRF_GPIO-&amp;gt;OUTCLR&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mixing c &amp; assembly in Keil IDE</title><link>https://devzone.nordicsemi.com/thread/36591?ContentTypeID=1</link><pubDate>Mon, 26 Oct 2015 09:51:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc9fb21e-8fbd-43f4-8b9e-83b166219414</guid><dc:creator>lakshman</dc:creator><description>&lt;p&gt;Hi HungBui,
Yes I wrote NRF_GPIO-&amp;gt;OUT more than 18 times. yes I am aware it will update all 32 pins. I want to control 5 pins at the same cycle. if you use NRF_GPIO-&amp;gt;OUTSET NRF_GPIO-&amp;gt;OUTCLR to set/clear one or multiple pins you will be controlling one pin at a time.
Moreover I am using STRB rbyte ,[out,#0] so only 8 pins will get affected if it is output pin.&lt;/p&gt;
&lt;p&gt;Thanks and Regards
Lakshman,PMP,PMI-RMP&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mixing c &amp; assembly in Keil IDE</title><link>https://devzone.nordicsemi.com/thread/36590?ContentTypeID=1</link><pubDate>Fri, 23 Oct 2015 13:37:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdefa76e-59ed-436e-896d-882e5cb5edd0</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Lakshman,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry that I don&amp;#39;t really understand the code . You write to NRF_GPIO-&amp;gt;OUT 18 times ?&lt;/p&gt;
&lt;p&gt;Note that NRF_GPIO-&amp;gt;OUT; is a 32 bit register and each bit control one pin. Each write to it will update the value of all 32 pins.
You can also use NRF_GPIO-&amp;gt;OUTSET NRF_GPIO-&amp;gt;OUTCLR to set/clear one or multiple pins without affecting the other pin.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mixing c &amp; assembly in Keil IDE</title><link>https://devzone.nordicsemi.com/thread/36589?ContentTypeID=1</link><pubDate>Fri, 23 Oct 2015 02:16:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ab7791e-9cfc-4d16-a628-0769ebe55a89</guid><dc:creator>lakshman</dc:creator><description>&lt;p&gt;Hi Hung &amp;amp; Vidar,
Thanks for your response.Yes I went through still I am unable to use it in proper way. After browsing I found out that above asm code is for GNU compiler. For Keil its very easy you can just give the variable name &amp;quot;as is&amp;quot; like below&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void mixC_and_Assembly()
{
 volatile uint32_t  *out = &amp;amp;NRF_GPIO-&amp;gt;OUT;
 byte *_ptbytes = txBuf;
 byte *_ptbytes1 = &amp;amp;txBuf[32];
 uint32_t  rbyte;

   // out =%0
   //_ptbytes = %1
   //rbyte = %2

__asm  volatile
		{      
	        LDRB rbyte,[_ptbytes,#0]    //    rbyte = *_ptbytes
	        STR  rbyte,[out,#0]    //  *out = _ptbytes[0]
	
	        LDRB rbyte,[_ptbytes,#1]    //  rbyte = *_ptbytes
	        STR  rbyte,[out,#0]         //  *out = _ptbytes[1]
	   
	        LDRB rbyte,[_ptbytes,#2]    //  rbyte = *_ptbytes
	        STR  rbyte,[out,#0]         //  *out = _ptbytes[2]
	     
	        LDRB rbyte,[_ptbytes,#3]    //  rbyte = *_ptbytes
	        STR  rbyte,[out,#0]         //  *out = _ptbytes[3]
	
	 	    LDRB rbyte,[_ptbytes,#4]    //  rbyte = *_ptbytes
	        STR  rbyte,[out,#0]      
	        ......
	        .....
	        .....
	        ......
	
	        LDRB rbyte,[_ptbytes1,#16]           //  rbyte = *_ptbytes1
	        STR  rbyte,[out,#0]             //  *out = _ptbytes1[16]
	 
	        LDRB rbyte,[_ptbytes1,#17]           //  rbyte = *_ptbytes1
	        STR  rbyte,[out,#0]             //  *out = _ptbytes1[17]
      
		}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am using p0.2,p0.3and p0.4 .If I give use the assembly I am able to get expected result but all the led is ON.
volatile uint32_t  *out = &amp;amp;NRF_GPIO-&amp;gt;OUT;
with the above statement I write to P0.2,P0.3 &amp;amp; P0.4 at the same time. will it have any effect on LED ? did I miss anything.?&lt;/p&gt;
&lt;p&gt;Thanks and Regards
Lakshman,PMP,PMI-RMP&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mixing c &amp; assembly in Keil IDE</title><link>https://devzone.nordicsemi.com/thread/36588?ContentTypeID=1</link><pubDate>Thu, 22 Oct 2015 13:05:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03c1a562-2c71-46e0-9c15-67a6f7ada0b4</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Just like to add that the asm syntax is not the same for Keil and the GNU arm toolchain.  bootloader_util.c shows the difference as Hung pointed out (SDK v8.1.0+).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mixing c &amp; assembly in Keil IDE</title><link>https://devzone.nordicsemi.com/thread/36587?ContentTypeID=1</link><pubDate>Thu, 22 Oct 2015 12:10:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07bfdbcc-8712-478c-b3a0-378e9aa96a84</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Lakshman,&lt;/p&gt;
&lt;p&gt;You can find an example of using ASM with C in KEIL in the bootloader_util.c for the bootloader project in our SDK. You can find the file in \components\libraries\bootloader_dfu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>