<?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: Setting Origin using C using HC(S)08 on the MC9S08GB60A in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158469#M9318</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;C language supports asm instructions; try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;asm {bsr 0x100;} /* branch to subroutine at 0x100 */&lt;/P&gt;&lt;P&gt;Take care of right syntax - the exmple above is for 9S12.&lt;/P&gt;&lt;P&gt;ipa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Dec 2009 18:20:42 GMT</pubDate>
    <dc:creator>ipa</dc:creator>
    <dc:date>2009-12-01T18:20:42Z</dc:date>
    <item>
      <title>Setting Origin using C using HC(S)08 on the MC9S08GB60A</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158467#M9316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;P&gt;We have a program which downloads data via serial comms in to RAM. Which is then&amp;nbsp;executed. For easy coding we are using C to code the block of code which is uploaded to the micro's RAM. This block of code changes depending on what is sent down the serial.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In asm instructions we would do the following&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ASM:&amp;nbsp;&lt;/P&gt;&lt;P&gt;;[use serial to download set of opcodes into $0100]&lt;/P&gt;&lt;P&gt;;then once download is complete&lt;/P&gt;&lt;P&gt;ORG $0100&lt;/P&gt;&lt;P&gt;;[code stored in memory now runs.]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would one do this in C? We are having trouble figuring out how to&amp;nbsp;define&amp;nbsp;an 'origin' in C so that this new code that is downloaded into RAM can be run.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are using a MC9S08GB60A.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help will be awesome!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Dec 2009 15:56:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158467#M9316</guid>
      <dc:creator>MrStackPointer</dc:creator>
      <dc:date>2009-12-01T15:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Origin using C using HC(S)08 on the MC9S08GB60A</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158468#M9317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well according to my understanding you are looking for a way to execute code stored at a specific address in RAM. Am I right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This can be done defining a constant function pointer and calling the function through the function pointer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;define the constant function pointer as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; void (*const fktPtr)(void) = (void(*)(void))0x100;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; in your code add a JSR to the code located at address 0x100:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; fktPtr();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;CrasyCat&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Dec 2009 18:19:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158468#M9317</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2009-12-01T18:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Origin using C using HC(S)08 on the MC9S08GB60A</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158469#M9318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;C language supports asm instructions; try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;asm {bsr 0x100;} /* branch to subroutine at 0x100 */&lt;/P&gt;&lt;P&gt;Take care of right syntax - the exmple above is for 9S12.&lt;/P&gt;&lt;P&gt;ipa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Dec 2009 18:20:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158469#M9318</guid>
      <dc:creator>ipa</dc:creator>
      <dc:date>2009-12-01T18:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Origin using C using HC(S)08 on the MC9S08GB60A</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158470#M9319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;For the code download itself, it must be OP-codes. There is no way around that.&lt;BR /&gt;To call the code at a specific address from C, you must do like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;typedef void(* FuncPtr_t)(void);&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;const uint16_t CODE_ADDRESS = 0x0100;&lt;BR /&gt;const FuncPtr_t func_ptr = (const FuncPtr_t)CODE_ADDRESS;&lt;BR /&gt;func_ptr();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The behavior of that code is well-defined by the C standard. If you want to pass parameters to the code, it becomes a bit more tricky on the function-side. On the caller-side, simply change the function pointer to one with parameters.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Dec 2009 18:29:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158470#M9319</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2009-12-01T18:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Origin using C using HC(S)08 on the MC9S08GB60A</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158471#M9320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the help guys.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although the address locations need to be modified so that all the REL jumps that the code does, take place in the RAM space you intend to place the code. If this is not done, then the C code will not execute&amp;nbsp;correctly&amp;nbsp;in RAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Dec 2009 18:23:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158471#M9320</guid>
      <dc:creator>MrStackPointer</dc:creator>
      <dc:date>2009-12-02T18:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Origin using C using HC(S)08 on the MC9S08GB60A</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158472#M9321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As Lundin has already indicated, the code being downloaded to the target will need to have been previously compiled and linked so that a binary image of the assembly/machine code is what is sent.&amp;nbsp; Or alternatively, perhaps use S19 format for an ASCII format file, which is easily converted to a binary image, and provides rudimentary error detection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The linking process will need to be controlled so that the execution location for the code is from the specific block of RAM memory, so that absolute jumps are to the correct address.&amp;nbsp; Relative jumps within the new code are not a problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Dec 2009 20:18:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Setting-Origin-using-C-using-HC-S-08-on-the-MC9S08GB60A/m-p/158472#M9321</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2009-12-02T20:18:18Z</dc:date>
    </item>
  </channel>
</rss>

