From Source Code - Kinetis Cortex M0+ Core

To set hardware tracepoints in the source code and collect trace data on the Kinetis Cortex M0+ project:

  1. In the CodeWarrior Projects view, select the Sources folder of your project.
  2. Double-click the source file, for example, main.c to display its contents in the editor area. Replace the source code of the main.c file with the source code shown below.
    Listing: Source code for trace collection
    #include "derivative.h" /* include peripheral declarations */
    
    #define MAX_IT 5
    
    #define SIMPLE
    
    
    
    typedef int(*FUNC_TYPE)(int);
    
    
    
    void Launch(FUNC_TYPE, int);
    
    void entry();
    
    void InterruptTest();
    
    
    
    int PerformanceWork(int);
    
    void Performance1(void);
    
    int Recursive(int);
    
    
    
    volatile char iteration = 0;
    
    
    
    void InterruptTest()
    
    {
    
    }
    
    
    
    void Launch(FUNC_TYPE f, int arg)
    
    {
    
         f(arg);
    
    }
    
    
    
    void entry()
    
    {
    
         Performance1();
    
         Recursive(1);
    
         Performance1();
    
    
    
         for (;iteration < MAX_IT;) {
    
             InterruptTest();
    
             Recursive(1);
    
             Performance1();
    
             Launch(PerformanceWork, iteration++);
    
         }
    
         for (;;) {
    
             if (iteration >= 255) iteration = 0;
    
         } /* loop forever */
    
    }
    
    
    
    int PerformanceWork (int iteration)
    
    {
    
         int ret = 0;
    
         if ( iteration & 1) {
    
              Performance1();
    
              ret = 1;
    
         }
    
         else {
    
              Recursive(1);
    
              ret = 2;
    
         }
    
         return ret;
    
    }
    
    
    
    void Performance1(void)
    
    {
    
    #ifndef SIMPLE
    
         int vecSize = 10;
    
         int vec[]={10,9,8,7,6,5,4,3,2,1};
    
    
    
         int i,aux;
    
    
    
         for (i=0; i<(vecSize/2) ;i++)
    
         {
    
             aux = vec[i];
    
             vec[i] = vec[vecSize-i-1];
    
             vec[vecSize-i-1] = aux;
    
         }
    
    #endif
    
    }
    
    
    
    int Recursive(int n)
    
    {
    
          /* Recursively calculates 0 + 1 + 2 + ... + n */
    
          if (n <= 0)
    
          {
    
              return 0;
    
          }
    
          else
    
          {
    
              return (n + Recursive(n-1));
    
          }
    
    }
    
    
    
    int main(void) {
    
          entry();
    
    /* please make sure that you never leave main */
    
    }
    
    
  3. Save the project.
  4. Open the Debug Configurations dialog box.
  5. Enable tracing and profiling using steps 3 - 11 of Configuring Kinetis Cortex M0+ Core.
  6. Select the Continuous option, click Apply, and close the dialog box..
  7. Set start and stop hardware tracepoints in main.c as shown below:
    Figure 1. Hardware Start and Stop Tracepoints
    Hardware Start and Stop Tracepoints
  8. Debug your project.
  9. Click Resume. After a few seconds, click Suspend.

    The Software Analysis view appears.

  10. Expand the project name and click the Timeline hyperlink to see the results.
    Figure 2. Timeline Results After Setting HW Tracepoints on Kinetis Cortex M0+ Project
    Timeline Results After Setting HW Tracepoints on Kinetis Cortex M0+ Project