Technical information
AN2216/D
8 MC9S12DP256 Software Development Using Metrowerkâs Codewarrior MOTOROLA
Compiling the
BANKED Memory
Model
The BANKED memory model is specified to the compiler with the option -Mb
on the compiler command line. If constant data variables located in paged
memory will be used, the options -CpPpage=RUNTIME -CpPpage=0x30 must
also be specified on the command line. If the Codewarrior IDE is being used,
Command line arguments are specified in the 'Compiler for HC12' dialogue in
'Target Settings Panels'.
Modification of
Startup Code for
MC9S12DP256
The _Startup function in version 1.2 of Codewarrior in file Start12.c has not
been targeted at the MC9S12DP256. The _Startup function initialises a
"WINDEF" register as shown in the code snippet in Figure 5.
/* Example : Set up WinDef Register to allow Paging */
#ifndef DG128 /* HC12 DG128 derivative has no WINDEF. Instead PPAGE is always enabled */
#if (__ENABLE_EPAGE__ != 0 || __ENABLE_DPAGE__ != 0 || __ENABLE_PPAGE__ != 0)
WINDEF= __ENABLE_EPAGE__ | __ENABLE_DPAGE__ | __ENABLE_PPAGE__;
#endif
#endif
Figure 5. Startup Code Snippet
The MC9S12DP256 has no such WINDEF register. In fact, the only MCU in the
HC12 family which has this register is the MC68HC812A4. The _Startup
function should therefore be modified so that it initialises the WINDEF register
only if the code is being compiled for the MC68HC812A4 MCU, as writes to the
WINDEF register address on other MCUs could cause unexpected results. It is
recommended that this piece of code is changed to that shown in Figure 6.
This change has been implemented in version 2.0 of the Codewarrior product.
/* Example : Set up WinDef Register to allow Paging on MC68HC812A4 */
#ifdef HC812A4
#if (__ENABLE_EPAGE__ != 0 || __ENABLE_DPAGE__ != 0 || __ENABLE_PPAGE__ != 0)
WINDEF= __ENABLE_EPAGE__ | __ENABLE_DPAGE__ | __ENABLE_PPAGE__;
#endif
#endif
Figure 6. Recommended _Startup Code Snippet
When compiling this code for the MC68HC812A4, the option -DHC812A4
would be specified on the compiler command line to enable this code when
required.
Modification of
Runtime Routines
for MC9S12DP256
A runtime routine must be used to access paged data on the MC9S12DP256.
The runtime routines supplied in version 1.2 of Codewarrior in file datapage.c
have not been targeted at the MC9S12DP256. If paged data will be accessed
in the application, it is recommended that the code snippet from datapage.c