<?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>CodeWarrior for MCUのトピックRe: Kinetis memcpy to 32-bit memory</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Kinetis-memcpy-to-32-bit-memory/m-p/307751#M10845</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Brian,&lt;/P&gt;&lt;P&gt;I have not tried this but feel free to give it a go.&lt;/P&gt;&lt;P&gt;In the PSP mqx_cnfg.h header is the following comments and "#define".&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14024562541714057" jivemacro_uid="_14024562541714057"&gt;
&lt;P&gt;/*&lt;/P&gt;
&lt;P&gt;** When this option is defined as 1, private MQX implementation of memcpy is used instead&lt;/P&gt;
&lt;P&gt;** the one from standard library.&lt;/P&gt;
&lt;P&gt;** MGCT: &amp;lt;option type="bool"/&amp;gt;&lt;/P&gt;
&lt;P&gt;*/&lt;/P&gt;
&lt;P&gt;#ifndef MQXCFG_MEM_COPY&lt;/P&gt;
&lt;P&gt;#define MQXCFG_MEM_COPY&amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;#endif&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you could and add "#define MQXCFG_MEM_COPY 1" in your user_config.h header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The mem_cpy() routine is also in PSP and in file mem_copy.c with following comments and initial function call:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_14024562541093170 jive_macro_code" jivemacro_uid="_14024562541093170"&gt;
&lt;P&gt;/*FUNCTION*-------------------------------------------------------------------
* 
* Function Name&amp;nbsp;&amp;nbsp;&amp;nbsp; : _mem_copy
* Returned Value&amp;nbsp;&amp;nbsp; : none
* Comments&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :
*&amp;nbsp;&amp;nbsp; This function copies the specified number of bytes from the
* source address to the destination address.&amp;nbsp; No attempt is made
* to handle overlapping copies to prevent loss of data.
*&amp;nbsp;&amp;nbsp; The copying is optimized to avoid alignment problems, and attempts
* to copy 32bit numbers optimally
*
*END*----------------------------------------------------------------------*/&lt;/P&gt;
&lt;P&gt;#if MQXCFG_MEM_COPY&lt;/P&gt;
&lt;P&gt;void _mem_copy
&amp;nbsp;&amp;nbsp; (
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* [IN] address to copy data from */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointer&amp;nbsp; from_ptr,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* [IN] address to copy data to */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointer&amp;nbsp; to_ptr,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* [IN] number of bytes to copy */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; register _mem_size number_of_bytes
&amp;nbsp;&amp;nbsp; )
{ /* Body */
#if MQX_USE_SMALL_MEM_COPY
&amp;nbsp;&amp;nbsp; register uint_8_ptr from8_ptr = (uint_8_ptr) from_ptr;
&amp;nbsp;&amp;nbsp; register uint_8_ptr to8_ptr = (uint_8_ptr) to_ptr;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if (number_of_bytes) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (number_of_bytes--) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *to8_ptr++ = *from8_ptr++;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } /* Endwhile */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; } /* Endif */
#else
&amp;nbsp;&amp;nbsp; uint_8_ptr from8_ptr = (uint_8_ptr) from_ptr;
&amp;nbsp;&amp;nbsp; uint_8_ptr to8_ptr = (uint_8_ptr) to_ptr;
&amp;nbsp;&amp;nbsp; uint_16_ptr from16_ptr = (uint_16_ptr) from_ptr;
&amp;nbsp;&amp;nbsp; uint_16_ptr to16_ptr = (uint_16_ptr) to_ptr;
&amp;nbsp;&amp;nbsp; register uint_32_ptr from32_ptr = (uint_32_ptr) from_ptr;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Jun 2014 18:26:32 GMT</pubDate>
    <dc:creator>DavidS</dc:creator>
    <dc:date>2014-06-10T18:26:32Z</dc:date>
    <item>
      <title>Kinetis memcpy to 32-bit memory</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Kinetis-memcpy-to-32-bit-memory/m-p/307749#M10843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using a K61 with MQX 4.0.2, CW 10.5, GCC 4.7.3 and&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; 32-bit Flexbus memory. I would like to use memcpy with this memory. My accesses are all aligned, however, I see that the EWL version of memcpy will always uses byte access (I was expecting some optimizations to be there for long accesses).&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found mem_funcs.h functions and tried them as well with various issues.&lt;/P&gt;&lt;P&gt;__copy_mem - has the exact same behavior as memcpy unless the size is &amp;gt; 32 bytes.&lt;/P&gt;&lt;P&gt;__copy_longs_aligned - seems to have some bugs as the addresses are predecremented and get the incorrect data. I can work around it by sending the wrong addresses into the function, but this is ugly.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone else worked with the memory functions to optimize for performance and long words?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Brian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 00:14:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Kinetis-memcpy-to-32-bit-memory/m-p/307749#M10843</guid>
      <dc:creator>brianmitchell</dc:creator>
      <dc:date>2014-05-29T00:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis memcpy to 32-bit memory</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Kinetis-memcpy-to-32-bit-memory/m-p/307750#M10844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Brian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A service request was created for you regarding this question. You will be contacted by technical support team.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Carlos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2014 18:07:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Kinetis-memcpy-to-32-bit-memory/m-p/307750#M10844</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2014-06-10T18:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis memcpy to 32-bit memory</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Kinetis-memcpy-to-32-bit-memory/m-p/307751#M10845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Brian,&lt;/P&gt;&lt;P&gt;I have not tried this but feel free to give it a go.&lt;/P&gt;&lt;P&gt;In the PSP mqx_cnfg.h header is the following comments and "#define".&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14024562541714057" jivemacro_uid="_14024562541714057"&gt;
&lt;P&gt;/*&lt;/P&gt;
&lt;P&gt;** When this option is defined as 1, private MQX implementation of memcpy is used instead&lt;/P&gt;
&lt;P&gt;** the one from standard library.&lt;/P&gt;
&lt;P&gt;** MGCT: &amp;lt;option type="bool"/&amp;gt;&lt;/P&gt;
&lt;P&gt;*/&lt;/P&gt;
&lt;P&gt;#ifndef MQXCFG_MEM_COPY&lt;/P&gt;
&lt;P&gt;#define MQXCFG_MEM_COPY&amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;#endif&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you could and add "#define MQXCFG_MEM_COPY 1" in your user_config.h header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The mem_cpy() routine is also in PSP and in file mem_copy.c with following comments and initial function call:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_14024562541093170 jive_macro_code" jivemacro_uid="_14024562541093170"&gt;
&lt;P&gt;/*FUNCTION*-------------------------------------------------------------------
* 
* Function Name&amp;nbsp;&amp;nbsp;&amp;nbsp; : _mem_copy
* Returned Value&amp;nbsp;&amp;nbsp; : none
* Comments&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :
*&amp;nbsp;&amp;nbsp; This function copies the specified number of bytes from the
* source address to the destination address.&amp;nbsp; No attempt is made
* to handle overlapping copies to prevent loss of data.
*&amp;nbsp;&amp;nbsp; The copying is optimized to avoid alignment problems, and attempts
* to copy 32bit numbers optimally
*
*END*----------------------------------------------------------------------*/&lt;/P&gt;
&lt;P&gt;#if MQXCFG_MEM_COPY&lt;/P&gt;
&lt;P&gt;void _mem_copy
&amp;nbsp;&amp;nbsp; (
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* [IN] address to copy data from */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointer&amp;nbsp; from_ptr,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* [IN] address to copy data to */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointer&amp;nbsp; to_ptr,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* [IN] number of bytes to copy */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; register _mem_size number_of_bytes
&amp;nbsp;&amp;nbsp; )
{ /* Body */
#if MQX_USE_SMALL_MEM_COPY
&amp;nbsp;&amp;nbsp; register uint_8_ptr from8_ptr = (uint_8_ptr) from_ptr;
&amp;nbsp;&amp;nbsp; register uint_8_ptr to8_ptr = (uint_8_ptr) to_ptr;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if (number_of_bytes) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (number_of_bytes--) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *to8_ptr++ = *from8_ptr++;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } /* Endwhile */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; } /* Endif */
#else
&amp;nbsp;&amp;nbsp; uint_8_ptr from8_ptr = (uint_8_ptr) from_ptr;
&amp;nbsp;&amp;nbsp; uint_8_ptr to8_ptr = (uint_8_ptr) to_ptr;
&amp;nbsp;&amp;nbsp; uint_16_ptr from16_ptr = (uint_16_ptr) from_ptr;
&amp;nbsp;&amp;nbsp; uint_16_ptr to16_ptr = (uint_16_ptr) to_ptr;
&amp;nbsp;&amp;nbsp; register uint_32_ptr from32_ptr = (uint_32_ptr) from_ptr;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2014 18:26:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Kinetis-memcpy-to-32-bit-memory/m-p/307751#M10845</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2014-06-10T18:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis memcpy to 32-bit memory</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Kinetis-memcpy-to-32-bit-memory/m-p/307752#M10846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Update: This has been fixed in Codewarrior 10.6!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2015 23:13:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Kinetis-memcpy-to-32-bit-memory/m-p/307752#M10846</guid>
      <dc:creator>brianmitchell</dc:creator>
      <dc:date>2015-04-23T23:13:41Z</dc:date>
    </item>
  </channel>
</rss>

