<?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 Re: simple pointer question CW5.7 9s08re16 in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188560#M4643</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I would change address to a pointer and change the address to point to an unsigned char (I am&amp;nbsp;guess you are writing&amp;nbsp;1 byte at a time)&amp;nbsp;so the function declaration would look like this:&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;void di_in_ram(unsigned char command, unsigned&amp;nbsp;char *address, unsigned char data)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;then if you want to write '$' to 0x400 you can cast 0x400 to be a pointer in the call&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;di_in_ram(WRITE_DATA,(unsigned int *)0x400,'$');&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In function di_in_ram you then set what is pointed to by address to data with:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;*address = data;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is follow by the flash writing process that you seem to be aware of.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Feb 2008 02:10:47 GMT</pubDate>
    <dc:creator>allawtterb</dc:creator>
    <dc:date>2008-02-12T02:10:47Z</dc:date>
    <item>
      <title>simple pointer question CW5.7 9s08re16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188556#M4639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I want to store a char variable into an int address (storeing data byte to Flash) and call a routine&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;void di_in_ram(unsigned char command, unsigned int address, unsigned char data)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;where "command" is put into one of the flash registers to tell it what action is required (erase or write)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"address" is the 16 bit address I want to write to&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"data is the 8 bit byte to be written.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know this involves pointers and I have read C books and tried various code which either produces compiler errors or fails to work (I won't bore you with them).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could someone tell me how to achieve this. It's probably just two or three lines of code, but, for the life of me, I can't seem to get it sorted. It must be a Monday morning thing, or else I'm just getting too old!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2008 19:28:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188556#M4639</guid>
      <dc:creator>stevec</dc:creator>
      <dc:date>2008-02-11T19:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: simple pointer question CW5.7 9s08re16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188557#M4640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am a little bit confused here.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;You cannot write to flash using a simple assignment in C. You need to go through some flash programming routines.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;writing to flash requires a special algorithm and adequate timing. So writing appropriate code here is not just a matter of programming in C.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Did you check the available application notes on the Freescale web page?&lt;/DIV&gt;&lt;DIV&gt;There might be some sample code for doing that there. Not sure you find it for RE16, but you might find a pretty similar MCU.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;CrasyCat&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2008 23:07:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188557#M4640</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2008-02-11T23:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: simple pointer question CW5.7 9s08re16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188558#M4641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thanks for the reply.&lt;BR /&gt;&lt;BR /&gt;I have a thread on "CW for 8 bit micros" which questioned writing to flash. I am using TN228 as the basis to write ROM code to RAM and execute from there. The routine "do_in_ram" mentioned here follows the methods detailed in the reference HC08 reference manual under FLASH application notes. I am aware of the stucture required to write to Flash.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2008 23:34:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188558#M4641</guid>
      <dc:creator>stevec</dc:creator>
      <dc:date>2008-02-11T23:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: simple pointer question CW5.7 9s08re16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188559#M4642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;All I am trying to do is to write a byte to a specified memory location, both of which are passed into the routine which handles operations on&amp;nbsp; the Flash. Firstly to erase the flash block, which requires a dummy byte to be written to the block to be erased. Secondly I need to then be able to write a byte into a location within that block. These operations are not stand alone but are involved in the routine that operates the flash access. The code for this access is run from RAM.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2008 01:54:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188559#M4642</guid>
      <dc:creator>stevec</dc:creator>
      <dc:date>2008-02-12T01:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: simple pointer question CW5.7 9s08re16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188560#M4643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I would change address to a pointer and change the address to point to an unsigned char (I am&amp;nbsp;guess you are writing&amp;nbsp;1 byte at a time)&amp;nbsp;so the function declaration would look like this:&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;void di_in_ram(unsigned char command, unsigned&amp;nbsp;char *address, unsigned char data)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;then if you want to write '$' to 0x400 you can cast 0x400 to be a pointer in the call&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;di_in_ram(WRITE_DATA,(unsigned int *)0x400,'$');&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In function di_in_ram you then set what is pointed to by address to data with:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;*address = data;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is follow by the flash writing process that you seem to be aware of.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2008 02:10:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188560#M4643</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2008-02-12T02:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: simple pointer question CW5.7 9s08re16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188561#M4644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thanks very much for that. You have defined the function as&lt;BR /&gt;&lt;BR /&gt;void di_in_ram(unsigned char command, unsigned&amp;nbsp;char *address, unsigned char data)&lt;BR /&gt;&lt;BR /&gt;but used the call&lt;BR /&gt;&lt;BR /&gt;di_in_ram(WRITE_DATA,(unsigned int *)0x400,'$');&lt;BR /&gt;&lt;BR /&gt;was this meant to be (unsigned char *)0x400 or should the function be defined with unsigned int *address?&lt;BR /&gt;&lt;BR /&gt;I am assuming it should be unsigned char * as it is a pointer to a char.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Steve&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2008 03:43:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188561#M4644</guid>
      <dc:creator>stevec</dc:creator>
      <dc:date>2008-02-12T03:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: simple pointer question CW5.7 9s08re16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188562#M4645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;You are correct, when I put in the change to use an unsigned char instead of unsigned int I forgot to change the part that cast it.&amp;nbsp; If you don't want to cast every call you can just define the function as&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;void di_in_ram (unsigned char command, unsigned int address, unsigned char data){   unsigned char *p_address;   ....   p_address = (unsigned char *)address;   ....}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;In this case you want the address to be an unsigned int, you can then call it without the cast:&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;di_in_ram(WRITE_DATA,0x400,'$');&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:39:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/simple-pointer-question-CW5-7-9s08re16/m-p/188562#M4645</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2020-10-29T09:39:51Z</dc:date>
    </item>
  </channel>
</rss>

