HCS08

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.

  1. Create a stationary project.
  2. Open the source code editor area.
  3. Replace the source code written in the main() function with the source code shown below:
    Listing: Configuration of DBGC and DBGT registers in main() function for HCS08 target
    void main(void)
    {
       EnableInterrupts; 
       DBGT = 0x80;   // write debug trigger register
       DBGC = 0xC0;   // write debug control register
    
      for(;;) {
            __RESET_WATCHDOG();
            foo();
        }
    }
  4. Save and build the project.
  5. Open the Debug Configurations dialog box, and select your project in the tree structure.
  6. Click the Trace and Profile tab, and check the Enable Trace and Profile checkbox.
  7. Check the Configuration Set in User Code checkbox in the User Options group. The rest of the controls on the page turn disabled.
  8. Click Apply to save the settings.
  9. Click Debug to debug the application.
  10. Click Resume to resume the execution and begin measurement. Let the application run for several seconds.
  11. Click Suspend .
  12. Open the Trace Data viewer following the steps explained in the topic Viewing Data to view the collected data.

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