Hi,
Some more tips you could use:
Looking at the project's map file you'll be able to grab some useful information. At the "OBJECT-ALLOCATION SECTION" you will find the absolute address, size and number of references to all symbols used by your application.
Locate the variable with the highest address: this one is the most likely to be written by undesired stack overflow conditions. You can start a debug section and monitor the state of this variable. Any unexpected change may be a symptom of a stack overflow.
You can instruct the linker to use the direct page with a small adjustment in the project's PRM file:
In the PLACEMENT section, just add the the Z-RAM segment into the placement of the DEFAULT_RAM. Something like this: DEFAULT_RAM INTO RAM, Z_RAM;
You can also manually place variables with high number of references into the direct page by using:
Code:
#pragma DATA_SEG __SHORT_SEG MY_ZEROPAGEunsigned near char my_direct_char_variable;
unsigned near int my_direct_int_variable;
#pragma DATA_SEG DEFAULT
Note that placing variables into direct page like this has a major advantage (considering you are using the small memory model): the code size is reduced because direct page variables consume less FLASH as the instructions using direct addressing mode are 1 byte shorter then those using extended addressing mode.
#MARKETING ON
You could also take a look at this book:
HCS08 Unleashed . It has many examples and could be useful

#MARKETING OFF
Best regards,