AnsweredAssumed Answered

9S08AC128 Paged Memory Programming using Code Warrior 6.3

Question asked by William Blum on Oct 11, 2012
Latest reply on Oct 16, 2012 by William Blum

Anyone here willing to share some examples of paged programming using CW? We would like to see how others solve the page programming challenge.


In our case we have an operationial issue that is giving us fits.

Here's the background:  a small product was created using the 9S08AC128. We were planning for expansion from the start.  Not much memory requried initially.  But, like all ongoing ventures, marketing wanted more functionality which means more memory.  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.  The first project expanded on the current, non-paged code set.  It was was created using the small memory model for AC128. The project was created using CW.  The application code was integrated and thoroughly tested and operates as designed.  The second project would implement memory paging.  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.  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:  #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.  We dis-assembled the target module and found RTC in place of RTS.  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.  Reading the .S19 file shows S1 data records in the 0x8000 range (S1238000nnnnnn).

We modified the .prm file by adding a new line in the PLACEMENT area:  PAGED_FLASH INTO P_PAGE2.  Commented P_PAGE2 out of the PAGED_ROM line and changed the #pragma segment names to PAGED_FLASH in the targeted module.  Compilation now produces S2 records with address fields: 0x028nnn.  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:


  ClearRegBits(TPM2C0SC, 0x80);         /* Wait 8uS */

  while ( (TPM2C0SC & 0x80) == 0);      /* */



Comment the while loop out and execution continues on but then stops at unrelated code.  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.  This leaves issues with settings in CW, banked setup or code or

one of the associated apps.


What are we missing?


Thoughts? Comments? Assistance? Code examples?


Thank you!