ColdFire V1

For ColdFire V1, the trace registers are not mapped in the memory space. Therefore, the only way to access these registers is by using the wdebug instruction, while the processor is running in the supervisor mode.

To configure the trace registers in the source code in the Automatic mode on the ColdFire V1 target:

  1. Create a stationary project.
  2. Open the source code editor area.
  3. Replace the source code of main.c with the source code shown below:
    Listing: Configuration of trace registers for ColdFire V1
    #include <hidef.h> /* for EnableInterrupts macro */
    
    #include "derivative.h" /* include peripheral declarations */
    
    #include <stdio.h>
    
    #include <ctype.h>
    
    
    
    /* Define the used DRc */
    
    #define MCFDEBUG_CSR 0x0  /* Configuration status*/
    
    #define MCFDEBUG_XCSR 0x1 /* Extended configuration status register*/
    
    #define MCFDEBUG_CSR2 0x2 /* Configuration status register 2 */
    
    #define TRACE_AUTOMATIC 0
    
    #define TRACE_CONTINUOUS 1
    
    #define TRACE_PCSYNC 2
    
    #define TRACE_NONE 3
    
    #define TRACE_MODE TRACE_AUTOMATIC
    
    
    
    volatile unsigned short dbg_spc[6];
    
    volatile unsigned short *dbg;
    
    
    
    inline void wdebug(int reg, unsigned long data) {
    
    
    
     // Force alignment to long word boundary
    
    
    
     dbg = (unsigned short *)((((unsigned long)dbg_spc) + 3) & 0xfffffffc);
    
    
    
     // Build up the debug instruction
    
     dbg[0] = 0x2c80 | (reg & 0xf);
    
     dbg[1] = (data >> 16) & 0xffff;
    
     dbg[2] = data & 0xffff;
    
     dbg[3] = 0;
    
     asm("    MOVE.L dbg ,A1");
    
     asm("    WDEBUG (A1) ");
    
    }
    
    
    
    inline void setSupervisorModel(void)
    
    {
    
      asm ( "    MOVE.W #0x2000,D0" );
    
      asm ( "    MOVE.W D0,SR" );
    
    }
    
    
    
    void main(void) {
    
    
    
      EnableInterrupts;
    
    
    
      /* include your code here */
    
    
    
      setSupervisorModel(); /* set CPU supervisor programming model */
    
    
    
    #if TRACE_MODE == TRACE_AUTOMATIC  /* set automatic trace mode */
    
      wdebug(MCFDEBUG_CSR, 0x200);
    
      wdebug(MCFDEBUG_XCSR, 0x1);
    
      wdebug(MCFDEBUG_CSR2, 0xC1);
    
    
    
    #elif TRACE_MODE == TRACE_CONTINUOUS  /* set continuous trace mode */
    
      wdebug(MCFDEBUG_CSR, 0x200);
    
      wdebug(MCFDEBUG_XCSR, 0x0);
    
      wdebug(MCFDEBUG_CSR2, 0x89);
    
    
    
    #elif TRACE_MODE == TRACE_PCSYNC  /* set PCSync trace mode */
    
      wdebug(MCFDEBUG_CSR, 0x200);
    
      wdebug(MCFDEBUG_XCSR, 0x3);
    
      wdebug(MCFDEBUG_CSR2, 0x99);
    
    
    
    #endif
    
    
    
      for(;;) {
    
        __RESET_WATCHDOG(); /* feeds the dog */
    
      }   
    
    }
  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. 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 using the source code. To set triggers, enable the triggers by including the following definition in your source code.


  #define ENABLE_TRIGGERS True  /* Enabling triggers */



  

Also, include the statements shown in the listing below in the main() function.

Listing: Setting triggers using source code in ColdFire V1
#if TRACE_MODE == TRACE_AUTOMATIC  /* set automatic trace mode */

 #if ENABLE_TRIGGERS == True  // with trigger points



  wdebug(MCFDEBUG_PBR0, 0x5F2); //set PBR0 register;trigger A at 0x5F2

  wdebug(MCFDEBUG_PBR1, 0x6C8); //set PBR1 register;trigger B at 0x6C8

   wdebug(MCFDEBUG_PBMR, 0x0);

   wdebug(MCFDEBUG_AATR, 0xE401);

   wdebug(MCFDEBUG_DBR, 0x0);

   wdebug(MCFDEBUG_DBMR, 0x0);

   wdebug(MCFDEBUG_TDR, 0x40006002);



 #endif



   // without trigger points

   wdebug(MCFDEBUG_CSR, 0x200);

   wdebug(MCFDEBUG_XCSR, 0x1);

   wdebug(MCFDEBUG_CSR2, 0xC1);



#elif TRACE_MODE == TRACE_CONTINUOUS /* set continuous trace mode */



 #if ENABLE_TRIGGERS == True  // with trigger points

   wdebug(MCFDEBUG_PBR0, 0x5F2); //set PBR0 register;trigger A at 0x5F2

   wdebug(MCFDEBUG_PBR1, 0x6C8); //set PBR1 register;trigger B at 0x6C8

   wdebug(MCFDEBUG_PBMR, 0x0);

   wdebug(MCFDEBUG_AATR, 0xE401);

   wdebug(MCFDEBUG_DBR, 0x0);

   wdebug(MCFDEBUG_DBMR, 0x0);

   wdebug(MCFDEBUG_TDR, 0x40006002);



 #endif  

  // without trigger points

  wdebug(MCFDEBUG_CSR, 0x200);

  wdebug(MCFDEBUG_XCSR, 0x0);

  wdebug(MCFDEBUG_CSR2, 0x89);



#elif TRACE_MODE == TRACE_PCSYNC  /* set PCSync trace mode */

  wdebug(MCFDEBUG_CSR, 0x200);

  wdebug(MCFDEBUG_XCSR, 0x3);

  wdebug(MCFDEBUG_CSR2, 0x99);



#else

  /* None */

  wdebug(MCFDEBUG_CSR, 0x0);

  wdebug(MCFDEBUG_XCSR, 0x0);

  wdebug(MCFDEBUG_CSR2, 0x0);



#endif

Note: The default setting of the TRACE_MODE compiler switch is TRACE_AUTOMATIC. To configure trace in the Continuous mode, set the compiler switch to TRACE_CONTINUOUS in the source code shown in Listing: Configuration of trace registers for ColdFire V1. To configure trace in the Profile-Only mode, set the compiler switch to TRACE_PCSYNC in the source code shown in Listing: Configuration of trace registers for ColdFire V1.