<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPCXpresso IDEのトピックRe: placing an array at a specific mem location</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554238#M13142</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Thu Feb 28 07:40:58 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;:confused:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why don't you just handle your buffers with memcpy :confused:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 23:34:13 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T23:34:13Z</dc:date>
    <item>
      <title>placing an array at a specific mem location</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554235#M13139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ECamino on Wed Feb 27 15:11:50 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have an api call that returns a pointer and reserves 8 bytes of data.&amp;nbsp; I later need that pointer for another api call.&amp;nbsp; But I need to use the reserved data as an array and so I need a way to make an array be at the address given by the pointer.&amp;nbsp; How do I put the array at the pointer location?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;uint8_t * ptr;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;uint8_t array[8];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ptr = api_call();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// array = api_call(); doesnt work&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// put array[] at address returned by ptr...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// populate array[]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;api2_call(ptr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;EC&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:34:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554235#M13139</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: placing an array at a specific mem location</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554236#M13140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ex-kayoda on Wed Feb 27 16:51:43 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: ECamino&lt;/STRONG&gt;&lt;BR /&gt;... I need a way to make an array be at the address given by the pointer&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That's not possible. You can't change declaration address of your array. Is there a special reason why you don't use the pointer (like the rest of the world) :confused:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:34:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554236#M13140</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: placing an array at a specific mem location</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554237#M13141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ECamino on Thu Feb 28 07:35:38 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:34:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554237#M13141</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: placing an array at a specific mem location</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554238#M13142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Thu Feb 28 07:40:58 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;:confused:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why don't you just handle your buffers with memcpy :confused:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:34:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554238#M13142</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: placing an array at a specific mem location</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554239#M13143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ECamino on Thu Feb 28 08:03:55 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;If I did something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;int main() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;char buff[8] = "8 Bytes!";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;char * pdata;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;memcpy (pdata, &amp;amp;buff[0], sizeof (pdata));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pdata would point to a copy of the data. But I would have to use more ram (still using two bufferes), and I'd use more program memory (and probably more ram) for the call and running the func...:(&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:34:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554239#M13143</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: placing an array at a specific mem location</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554240#M13144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by wrighflyer on Thu Feb 28 10:20:48 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't understand why you need array[] at all. ptr is the base of an array. You can use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;ptr = api_call();
uint8_t val = ptr[3];&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;When you write ptr[3] in C it is immediately broken down as if you had written *(ptr + 3). Array accessing syntax [N] is just syntactic sugar for pointer access anyway.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:34:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554240#M13144</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: placing an array at a specific mem location</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554241#M13145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ECamino on Thu Feb 28 11:29:33 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks wrightflyer!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I did find a way that works great:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;uint8_t * ptr;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ptr = api_call();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(more code)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ptr[0] = x;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ptr[1] = y;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:34:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554241#M13145</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: placing an array at a specific mem location</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554242#M13146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Thu Feb 28 13:00:11 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;And with a struct and memcopy it looks good also &lt;SPAN class="lia-unicode-emoji" title=":winking_face:"&gt;&lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
uint8_t * ptr;

typedef struct{
 uint8_t x;
 uint8_t y;
}struct_position;&amp;nbsp; //struct to enable memcopy of a block
struct_position position;

ptr = api_call();

(more code)

memcpy(ptr, &amp;amp;position, (sizeof(struct_position)));

(more)

pUsbApi-&amp;gt;hw-&amp;gt;WriteEP(hUsb, 0x82, ptr, 8);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:34:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554242#M13146</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: placing an array at a specific mem location</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554243#M13147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ECamino on Thu Feb 28 14:46:50 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, Zero!&amp;nbsp; That's a more elegant way to do it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;EC&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:34:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/placing-an-array-at-a-specific-mem-location/m-p/554243#M13147</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:34:16Z</dc:date>
    </item>
  </channel>
</rss>

