<?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: Printf() in Banked Memory Model (HCS12)</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137414#M2003</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 would recommend you to look at the FAQ-27439 on Freescale web site.&lt;/DIV&gt;&lt;DIV&gt;This FAQ explains you what you need to care about if you want to allocate string constants in banked memory.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I assume you did nor generate a new version of ANSI library supporting banked string constants.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Also note that the process is different for HCS12 &amp;amp; HCS12X.&lt;/DIV&gt;&lt;DIV&gt;I hope this helps.&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, 16 Jul 2007 14:25:29 GMT</pubDate>
    <dc:creator>CrasyCat</dc:creator>
    <dc:date>2007-07-16T14:25:29Z</dc:date>
    <item>
      <title>Printf() in Banked Memory Model (HCS12)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137408#M1997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am facing some problems using printf(). It works nicely in large memory model, but in banked memory model, I am forced to allocate STRINGS in the nonbanked section, which isn't very nice because we don't have a lot of unbanked space. Is it possible to make printf() work in banked memory model with arguments in banked ROM/RAM? If so, how? The code I get seems to hand over 16bit pointers only.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried recompiling the lib, and the code I got actually handed over 3 bytes, but the page part was always 0.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Nov 2006 19:38:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137408#M1997</guid>
      <dc:creator>vectorio</dc:creator>
      <dc:date>2006-11-21T19:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: Printf() in Banked Memory Model (HCS12)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137409#M1998</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;In banked memory model, the predefined section STRINGS contains per definition objects accessed with 16-bit address.&lt;/DIV&gt;&lt;DIV&gt;If you wish to get some string constants allocated in banked memory you have to define them in a user defined string section&amp;nbsp;defined with qualifier _PPAGE_SEG.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For example&lt;/DIV&gt;&lt;DIV&gt;#pragma STRING_SEG __PPAGE_SEG MyFarString&lt;/DIV&gt;&lt;DIV&gt;/* Define your strings here */&lt;/DIV&gt;&lt;DIV&gt;#pragma STRING_SEG DEFAULT&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Also make sure to build your application with -CpPPAGE=RUNTIME to let the compiler know it should use a run time function to access banked strings.&lt;/DIV&gt;&lt;DIV&gt;Also make sure that you activate that option when you rebuild the ANSI libraries.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I assume you have redefined the macro LIBDEF_FAR_CONST_STRINGS, LIBDEF_FAR_STRINGS when building the libraries.&amp;nbsp;&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>Tue, 21 Nov 2006 20:20:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137409#M1998</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-11-21T20:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Printf() in Banked Memory Model (HCS12)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137410#M1999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Many thanks, it works!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;However, if I use something like&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;printf("Good morning");&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;this "implicitly" creates a constant string... how can I influence where it is placed? Is it possible to tell the compiler that I want it in __PPAGE_SEG?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Nov 2006 21:28:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137410#M1999</guid>
      <dc:creator>vectorio</dc:creator>
      <dc:date>2006-11-21T21:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Printf() in Banked Memory Model (HCS12)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137411#M2000</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;Did you try to put the pragma STRING_SEG prior to the implementation of the function where you have the printf?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This should do the trick (in my opinion). All string constants within the function will then be allocated in the same user defined string section.&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>Wed, 22 Nov 2006 16:50:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137411#M2000</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-11-22T16:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Printf() in Banked Memory Model (HCS12)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137412#M2001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Well, yes I did, but I also put the DEFAULT pragma before it :smileywink: ... it works now. Again many thanks.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Nov 2006 16:53:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137412#M2001</guid>
      <dc:creator>vectorio</dc:creator>
      <dc:date>2006-11-22T16:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Printf() in Banked Memory Model (HCS12)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137413#M2002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;CrasyCat,&lt;BR /&gt;&lt;BR /&gt;I ran into the same problem with printf. I am following all the tricks you listed in this thread but it is still not quite right. Even I use the vprintf in printf.c&lt;BR /&gt;&lt;BR /&gt;After inspecting the assembly listing, the caller pushes the 16-bit address as well as the page number of the string onto the stack (note the page number used to be always zero, but not anymore after I applied the trick). I think this is correct and expected behavior.&lt;BR /&gt;&lt;BR /&gt;But I get garbage output. I noticed that if the string and vprintf() are in the same flash page then it prints correctly. Otherwise I get garbage. This suggests that vprintf() ignores the page number.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;I currently do not have LIBDEF_FAR_CONST_STRINGS, LIBDEF_FAR_STRINGS and place MyFarString in non-paged memory (small data, banked function) and it works fine. This method is suggested in this thread:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.freescale.com/freescale/board/message?board.id=CW816COMM&amp;amp;message.id=240&amp;amp;query.id=22084#M240" target="test_blank"&gt;http://forums.freescale.com/freescale/board/message?board.id=CW816COMM&amp;amp;message.id=240&amp;amp;query.id=22084#M240&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;You agreed with vectorio that strings must be in non-paged memory for it to work. But in this thread you implied that strings may be in any page (banked data, banked function). Can you clarify that?&lt;BR /&gt;&lt;BR /&gt;If you're sure that string can be anywhere then chances are I made some silly mistakes. What course of action would you recommend, such as experiments to find out what's worng?&lt;BR /&gt;&lt;BR /&gt;Sector&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Jul 2007 11:22:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137413#M2002</guid>
      <dc:creator>Sector</dc:creator>
      <dc:date>2007-07-14T11:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Printf() in Banked Memory Model (HCS12)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137414#M2003</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 would recommend you to look at the FAQ-27439 on Freescale web site.&lt;/DIV&gt;&lt;DIV&gt;This FAQ explains you what you need to care about if you want to allocate string constants in banked memory.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I assume you did nor generate a new version of ANSI library supporting banked string constants.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Also note that the process is different for HCS12 &amp;amp; HCS12X.&lt;/DIV&gt;&lt;DIV&gt;I hope this helps.&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, 16 Jul 2007 14:25:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Printf-in-Banked-Memory-Model-HCS12/m-p/137414#M2003</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2007-07-16T14:25:29Z</dc:date>
    </item>
  </channel>
</rss>

