Instruction Inside Range from Address A to Address B is Executed

The Instruction Inside Range from Address A to Address B is Executed trigger type is used to trigger on a program instruction execution inside the range, Address A - Address B, where Address A is the address at which trigger A is set and Address B is the address at which trigger B is set.

Note: For the MC9S08PT60 target specifically, the Instruction Inside Range from Address A to Address B is Executed trigger will hit when any instruction inside the range between trigger address A and trigger address B matches with the data on the bus or program address inside the range.

To collect trace using the Instruction Inside Range from Address A to Address B is Executed trigger type:

  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 in the main.c file with the source code shown below.
    Listing: Source code 2
    #include <hidef.h> /* for EnableInterrupts macro */
    
    #include "derivative.h" /* include peripheral declarations */
    
    #define MAX_IT 2
    
    #define SIMPLE 1
    
    typedef int(*FUNC_TYPE)(int);
    
    void entry();
    
    void InterruptTest();
    
    void ContextSwitch(FUNC_TYPE, int);
    
    int PerformanceWork (int);
    
    void Performance1(void);
    
    int Recursive(int);
    
    void Launch(FUNC_TYPE f, int arg)
    {
        f(arg);
    }
    
    void InterruptTest()
    {}
    
    void entry()
    {
      volatile int iteration =0;
      InterruptTest();
      for (iteration =0; iteration < MAX_IT; /*iteration^=1*/ iteration++)
      { Launch(PerformanceWork, iteration);}
    }
    
    int PerformanceWork (int iteration)
    {
       int ret = 0;
       if ( iteration & 1) {
             Performance1();
             ret = 1;
       }
       else {
             Recursive(3);
             ret = 2;
       }      
       return ret;
    }
    
    void Performance1(void)
    {
    }
    
    int Recursive(int n)
    {
       /* Recursively calculates 0 + 1 + 2 + ... + n */     
      if (n <= 0)    /* breakpoint here */
      {
         return 0;
      }
      else
      {
         return (n + Recursive(n-1));
      }
    }
    
    void main(void) {
    
     EnableInterrupts; /* enable interrupts */
      /* include your code here */
      Performance1();
      Recursive(2);
      Performance1();
      for(;;) {
       entry();
       __RESET_WATCHDOG(); /* feeds the dog */
    
      } /* loop forever */
    
    }
    
  3. Save and build the project.
  4. Open the Debug Configurations dialog box, and select your project in the tree structure.
  5. Click the Trace and Profile tab, and check the Enable Trace and Profile checkbox.
  6. Click Apply and close the Debug Configurations dialog box.
  7. Set trigger A at ret = 1; and trigger B at ret = 2; in the PerformanceWork() function.
    Figure 1. Setting Trigger A and Trigger B in Source Code - Instruction Inside Range
    Setting Trigger A and Trigger B in Source Code - Instruction Inside Range
  8. Open the Debug Configurations dialog box, and select your project in the tree structure.
  9. Click the Trace and Profile tab.
  10. Select the Collect Program Trace option in the Trace Mode Options group.
  11. Select the Continuously option.
  12. Select the Collect Trace From Trigger option in the Trace Start/Stop Conditions group.
  13. Clear the Keep Last Buffer Before Trigger checkbox.
  14. Ensure that the Instruction Execute option is selected in the Trigger Selection group.
  15. Select the Instruction Inside Range from Address A to Address B is Executed option from the Trigger Type drop-down list.
  16. Click Apply to save the settings.
  17. Click Debug to debug the application.
  18. Collect the trace data following the steps explained in the topic Collecting Data.
  19. Open the Trace Data viewer following the steps explained in the topic Viewing Data to view the collected data.

    The figure below shows the data files that are generated by the application in which trace starts from Recursive(3) (in PerformanceWork()), which is the first address that the application finds between trigger A ( ret = 1;) and trigger B ( ret = 2;) address range after hitting trigger A.

    Figure 2. Trace Data - Instruction Inside Range
    Trace Data - Instruction Inside Range
    Note: In the Instruction Inside Range from Address A to Address B is Executed trigger type, a time delay of one to four instructions, depending on the processor type, might occur when tracing starts.

This is how you can collect trace using the Instruction Inside Range from Address A to Address B is Executed trigger type.