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:
#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 */ } }
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.
#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