<?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>topic Can't modify a string when running program in CodeWarrior Development Tools</title>
    <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Can-t-modify-a-string-when-running-program/m-p/433597#M3020</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. Using the FRDM KE02 for developing a project (using CWIDE + processor expert), the following problem came up:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The program consists of the following: when pressing a button, the last pressed button, is saved in the variable (unsigned char last_pressed_button). That works correctly. What I want to do is to save this pressed buttons in a string (char * pressed_buttons). The problem is that when I want save the pressed buton (using: pressed_buttons[i] = last_pressed_button) the MCU misteriously stops running. &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing something wrong?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Jun 2015 15:59:16 GMT</pubDate>
    <dc:creator>juanignaciotroi</dc:creator>
    <dc:date>2015-06-05T15:59:16Z</dc:date>
    <item>
      <title>Can't modify a string when running program</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Can-t-modify-a-string-when-running-program/m-p/433597#M3020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. Using the FRDM KE02 for developing a project (using CWIDE + processor expert), the following problem came up:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The program consists of the following: when pressing a button, the last pressed button, is saved in the variable (unsigned char last_pressed_button). That works correctly. What I want to do is to save this pressed buttons in a string (char * pressed_buttons). The problem is that when I want save the pressed buton (using: pressed_buttons[i] = last_pressed_button) the MCU misteriously stops running. &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing something wrong?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 15:59:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Can-t-modify-a-string-when-running-program/m-p/433597#M3020</guid>
      <dc:creator>juanignaciotroi</dc:creator>
      <dc:date>2015-06-05T15:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Can't modify a string when running program</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Can-t-modify-a-string-when-running-program/m-p/433598#M3021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Juan Troisi:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From your description it seems you are not initializing that pointer (char* pressed_buttons) and from CodeWarrior startup it is likely that it is pointing to address 0, which is Flash memory and cannot be written to with a simple assignment, which results in a fault. Even initializing the pointer would not be such a good idea, as you are relying on it pointing to available space, but you could end up overwriting other variables, stack, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are better allocating memory for a defined size array, like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;char pressed_buttons[SIZE]; // Size depends on how long you require the string to be.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or reserving some space in the linker file only for the string, but this may be an overkill.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Jorge Gonzalez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 23:16:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Can-t-modify-a-string-when-running-program/m-p/433598#M3021</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2015-06-05T23:16:37Z</dc:date>
    </item>
  </channel>
</rss>

