<?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: 9S08AC128 Paged Memory Programming using Code Warrior 6.3 in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08AC128-Paged-Memory-Programming-using-Code-Warrior-6-3/m-p/216853#M18868</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Implemented your suggestions, especially pragmas at the ISRs.&amp;nbsp; The whole project now operates as expected.&lt;/P&gt;&lt;P&gt;Thanks for the suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Oct 2012 22:42:09 GMT</pubDate>
    <dc:creator>LDAA_STAB</dc:creator>
    <dc:date>2012-10-16T22:42:09Z</dc:date>
    <item>
      <title>9S08AC128 Paged Memory Programming using Code Warrior 6.3</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08AC128-Paged-Memory-Programming-using-Code-Warrior-6-3/m-p/216851#M18866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Anyone here willing to share some examples of paged programming using CW? We would like to see how others solve the page programming challenge.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In our case we have an operationial issue that is giving us fits.&lt;/P&gt;&lt;P&gt;Here's the background:&amp;nbsp; a small product was created using the 9S08AC128. We were planning for expansion from the start.&amp;nbsp; Not much memory requried initially.&amp;nbsp; But, like all ongoing ventures, marketing wanted more functionality which means more memory.&amp;nbsp; We had time so in order to gain some experience with the banked/ paged menory technique we decided to create two projects based on AC128.&amp;nbsp; The first project expanded on the current, non-paged code set.&amp;nbsp; It was was created using the small memory model for AC128. The project was created using CW.&amp;nbsp; The application code was integrated and thoroughly tested and operates as designed.&amp;nbsp; The second project would implement memory paging.&amp;nbsp; It was created using the banked memory model. Source files from the non-banked project were imported into the banked project. None of the source files were modified.&amp;nbsp; The banked project makes, loads to the target, and runs. The banked project contains several modules (files). One of the modules was selected and modified according to AN3730:&amp;nbsp; #pragma CODE_SEG PAGED_ROM and #pragma CODE_SEG DEFAULT surround the functional prototypes and functions in the module. The code makes and loads to the target hardware but does not run.&amp;nbsp; We dis-assembled the target module and found RTC in place of RTS.&amp;nbsp; We dis-assembled one of the other modules that contain functions that call the functions wrapped in #pragma CODE_SEG PAGED_ROM and found the CALL opcodes in place of JSR.&amp;nbsp; Reading the .S19 file shows S1 data records in the 0x8000 range (S1238000nnnnnn). &lt;/P&gt;&lt;P&gt;We modified the .prm file by adding a new line in the PLACEMENT area:&amp;nbsp; PAGED_FLASH INTO P_PAGE2.&amp;nbsp; Commented P_PAGE2 out of the PAGED_ROM line and changed the #pragma segment names to PAGED_FLASH in the targeted module.&amp;nbsp; Compilation now produces S2 records with address fields: 0x028nnn.&amp;nbsp; The code loads and can be viewed from the debugger (in page mode). The application starts but promply bombs out. Breakpointing our way through the code from reset forward indicates a while loop test associated with a timer causes the crash:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ClearRegBits(TPM2C0SC, 0x80);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Wait 8uS */&lt;/P&gt;&lt;P&gt;&amp;nbsp; while ( (TPM2C0SC &amp;amp; 0x80) == 0);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* */&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Comment the while loop out and execution continues on but then stops at unrelated code.&amp;nbsp; After the crash PC is at 0x0000, Stack points to the same address as before the crash. The source code was imported from a known good program.&amp;nbsp; This leaves issues with settings in CW, banked setup or code or&lt;/P&gt;&lt;P&gt;one of the associated apps.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; What are we missing?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thoughts? Comments? Assistance? Code examples?&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;P&gt; WmB&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2012 05:52:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08AC128-Paged-Memory-Programming-using-Code-Warrior-6-3/m-p/216851#M18866</guid>
      <dc:creator>LDAA_STAB</dc:creator>
      <dc:date>2012-10-12T05:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: 9S08AC128 Paged Memory Programming using Code Warrior 6.3</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08AC128-Paged-Memory-Programming-using-Code-Warrior-6-3/m-p/216852#M18867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Porting from Small to Banked memory model should be as easy as just telling&lt;BR /&gt;Project Wizard that you want Banked memory model. But with one main exception:&lt;BR /&gt;interrupt handlers. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL style="list-style-type: decimal;"&gt;&lt;LI&gt;Did you use #pragma TRAP_PROC, or did you use interrupt keyword, both&lt;BR /&gt;where OK in Small model, but are not enough in Banked model. You still need to&lt;BR /&gt;use TRAP_PROC or interrupt keyword to make interrupt handlers exiting with RTI&lt;BR /&gt;instruction, but since CPU doesn't bank switching when calling interrupt&lt;BR /&gt;handlers, you need to tell linker that interrupt handlers have to be allocated&lt;BR /&gt;in nonbanked memory. See below how&lt;/LI&gt;&lt;LI&gt;In case you are using pointers to "near" functions, you need to&lt;BR /&gt;use near keyword when defining such function pointers. Some users try to avoid&lt;BR /&gt;function pointers, but they still can have some vectors.c, in which they may&lt;BR /&gt;have array of pointers to near interrupt handlers. &lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is bit weird that CW 6.3 compiler requires two near keywords when&lt;BR /&gt;defining function pointers. It won’t compile if one of near’s below is missing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; void __near (* __near fptr)(void);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Allocation to nonbanked memory is done like you say putting prototypes and&lt;BR /&gt;function between pragmas:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG NON_BANKED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void near myfoo1(void);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void near myfoo2(void);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here ^^ NON_BANKED is PLACEMENT derfined in PRM&lt;BR /&gt;file. Additional to ^^ these two pragmas you need to use near keyword in front&lt;BR /&gt;of each prototype/define.&amp;nbsp; If you don’t&lt;BR /&gt;like near keyword, then you need to use __NEAR_SEG&lt;BR /&gt;attribute:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG __NEAR_SEG&lt;BR /&gt;NON_BANKED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void myfoo1(void);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void myfoo2(void);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__NEAR_SEG makes all functions near &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL style="list-style-type: disc;"&gt;&lt;LI&gt;Reading the .S19 file shows S1 data records in&lt;BR /&gt;the 0x8000 range (S1238000nnnnnn). &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is OK. PPAGE=0 , CPU address 0x8000 is also paged address. Since address&lt;BR /&gt;fits 16bits, burner uses S1 record to define banked code.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2012 08:16:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08AC128-Paged-Memory-Programming-using-Code-Warrior-6-3/m-p/216852#M18867</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2012-10-12T08:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: 9S08AC128 Paged Memory Programming using Code Warrior 6.3</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08AC128-Paged-Memory-Programming-using-Code-Warrior-6-3/m-p/216853#M18868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Implemented your suggestions, especially pragmas at the ISRs.&amp;nbsp; The whole project now operates as expected.&lt;/P&gt;&lt;P&gt;Thanks for the suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2012 22:42:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08AC128-Paged-Memory-Programming-using-Code-Warrior-6-3/m-p/216853#M18868</guid>
      <dc:creator>LDAA_STAB</dc:creator>
      <dc:date>2012-10-16T22:42:09Z</dc:date>
    </item>
  </channel>
</rss>

