<?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>S12 / MagniV MicrocontrollersのトピックCalling a user application function from bootloader</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Calling-a-user-application-function-from-bootloader/m-p/1409114#M18474</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to call a function from bootloader where the function is defined in user application.&lt;/P&gt;&lt;P&gt;How to execute this .&lt;/P&gt;&lt;P&gt;Could anyone help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Abhijith.P.R&lt;/P&gt;</description>
    <pubDate>Fri, 04 Feb 2022 17:23:19 GMT</pubDate>
    <dc:creator>AjRj14</dc:creator>
    <dc:date>2022-02-04T17:23:19Z</dc:date>
    <item>
      <title>Calling a user application function from bootloader</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Calling-a-user-application-function-from-bootloader/m-p/1409114#M18474</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to call a function from bootloader where the function is defined in user application.&lt;/P&gt;&lt;P&gt;How to execute this .&lt;/P&gt;&lt;P&gt;Could anyone help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Abhijith.P.R&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 17:23:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Calling-a-user-application-function-from-bootloader/m-p/1409114#M18474</guid>
      <dc:creator>AjRj14</dc:creator>
      <dc:date>2022-02-04T17:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a user application function from bootloader</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Calling-a-user-application-function-from-bootloader/m-p/1409280#M18475</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;if you know where the function is located and you know its prototype then you can create a pointer to a function and load it with the address of the function you want to call. Why it is important to know the prototype of the function? Because there are different return codes for far and near function. (RTC/RTS)...Calling function is via CALL or JSR. Plus you need to know its parameters.&lt;/P&gt;
&lt;P&gt;Moreover I'll deal with S12(X) device and not with MagniV (S12Z) device.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If called function is a far function. It has return code RTC.&lt;/P&gt;
&lt;P&gt;void (* far far_function)(void);&lt;/P&gt;
&lt;P&gt;If called function is a near function. It has return code RTS.&lt;/P&gt;
&lt;P&gt;void (* near far_function)(void);&lt;/P&gt;
&lt;P&gt;Note that pointer to a far function has following format :&lt;/P&gt;
&lt;P&gt;offset_page&lt;/P&gt;
&lt;P&gt;so if the function is located at address 0xPageOffset then you have to put adjusted number to a pointer.&lt;/P&gt;
&lt;P&gt;Calling a far function in the code:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;let function is at logical page 0x3E and its offset is 0x4444&lt;/P&gt;
&lt;P&gt;then, written in two code lines:&lt;/P&gt;
&lt;P&gt;far_function = (void(*far)()) 0x44443E&lt;/P&gt;
&lt;P&gt;far_function();&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Calling a near function in the code:&lt;/P&gt;
&lt;P&gt;let function is at the address 0xCCCC&lt;/P&gt;
&lt;P&gt;then, written in two lines:&lt;/P&gt;
&lt;P&gt;near_function = (void(*near)()) 0xCCCC;&lt;/P&gt;
&lt;P&gt;near_function();&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I have written this answer without testing but believe it will help you.&lt;/P&gt;
&lt;P&gt;When you solve such tasks I always suggest to step the code in assembler to see what is executed and whether there is nothing which can cause any issue. I mean also test execution of called function because it can use or set things which are not compatible with an idea and must be solved.&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Ladislav&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Feb 2022 17:12:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Calling-a-user-application-function-from-bootloader/m-p/1409280#M18475</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2022-02-06T17:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a user application function from bootloader</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Calling-a-user-application-function-from-bootloader/m-p/1409286#M18476</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&amp;nbsp;Ladislav,&lt;/P&gt;&lt;P&gt;I will try this and will update.&lt;/P&gt;&lt;P&gt;Could you please explain me why this kind of function call is needed in bootloader.? Why a normal call of a function defined in user application is not working when called in bootloader?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Feb 2022 19:09:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Calling-a-user-application-function-from-bootloader/m-p/1409286#M18476</guid>
      <dc:creator>AjRj14</dc:creator>
      <dc:date>2022-02-06T19:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a user application function from bootloader</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Calling-a-user-application-function-from-bootloader/m-p/1409291#M18477</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Have you already read &lt;A href="https://www.nxp.com/docs/en/application-note/AN4258.pdf" target="_blank"&gt;https://www.nxp.com/docs/en/application-note/AN4258.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;BTW, there could be misunderstanding between us. Have you created a bootloader and application in one project? If yes then the address of function is known otherwise not. I do not see what you really do but I believe the AN I mentioned above brings the light into the issue. Of course, something is a little bit different if you use MagniV device. In this case I suggest to look at &lt;A href="https://www.nxp.com/docs/en/application-note/AN4723.pdf" target="_blank"&gt;https://www.nxp.com/docs/en/application-note/AN4723.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Ladislav&lt;/P&gt;</description>
      <pubDate>Sun, 06 Feb 2022 21:05:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Calling-a-user-application-function-from-bootloader/m-p/1409291#M18477</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2022-02-06T21:05:07Z</dc:date>
    </item>
  </channel>
</rss>

