To setup the trace mode for HCS08, you must configure the DBGT and DBGC registers in the source code, preferably within the main() function and before any processing and/or functions calls. This is not mandatory but recommended as the main() function is called immediately after processor is reset. Therefore, to collect trace from this point forward, you must configure these registers in the beginning of the main() function.
You can configure only the Automatically mode for the HCS08 target. The Continuously and Profile-Only modes are implemented in the host software and there are no registers on the target associated with these modes.
For HCS08, the trace registers are mapped in the memory, so they have addresses associated. Therefore, you need to simply write desired values to these registers in the source code. An example to configure the trace registers in the source code of the HCS08 target is discussed below.
void main(void) { EnableInterrupts; DBGT = 0x80; // write debug trigger register DBGC = 0xC0; // write debug control register for(;;) { __RESET_WATCHDOG(); foo(); } }
You can also set triggers at the required addresses by writing the following statements in the main() function of your source code:
DBGCA = 0xE1CD; //write comparator A; sets trigger A at 0xE1CD DBGCB = 0xE1DB; //write comparator B; sets trigger B at 0xE1DB