Table of Contents

1. Generating code traces
2. Using the modify option for logging embedded code messages

1. Generating code traces

Special instruction inserted in the code can be used to report code behavior in WSim traces. A set of instruction can be inserted using the following macros on the MSP430:

	  #define MOV_R7R7()   __asm__ __volatile__ ("mov r7,r7")
	  #define TRACE1  MOV_R7R7
	  #define MOV_R8R8()   __asm__ __volatile__ ("mov r8,r8")
	  #define TRACE2  MOV_R8R8
	  [ ... ]
	  #define MOV_R15R15()   __asm__ __volatile__ ("mov r15,r15")
	  #define TRACE15  MOV_R15R15

These instructions have no effect on the application code except that they consume 2 CPU cycles. The presence of a MOV_RxRx will be reported in the traces.

Since traces will report only changes in the trace point ID you have to use at least two tracepoints in a loop to observe the changes. If the same tracepoint is used several times in a row then only the first one will be reported.

The following program illustrates the use of two breakpoints within a loop. Traces are reported in the msp430.breakpoints trace and is shown on the next figure using the GtkWave VCD viewer.


TRACE7 and TRACE8 are mapped within the code to start and stop recording traces. Using these two macros can enable partial traces that will result in smaller output files. Other breakpoints are free of use and only generate events in the trace file.

          volatile int my_global_variable;
          int main(void)
            WDTCTL = WDTPW | WDTHOLD;
            int i;
            for(i=0; i<1000; i++)
                my_global_variable = i;
            return 0;
Trace view of the msp430.breakpoints changes

Figure IV.1. Trace view of the msp430.breakpoints changes

2. Using the modify option for logging embedded code messages

The --monitor option has been extended in WSim to be able to output strings and decimal values from the simulation. The WSimLog.h file included int the SVN repository can be used to insert special function calls.


This mechanism uses a preallocated buffer that will be included in your application. Three functions are defined in order to log strings, chars, bytes and words out of the simulation. Messages are stored in the wsim.log file with a machine:monitor prefix pattern that can be used to retreive the information.

	void logChar   (char   ch);
	void logByte   (char   bt);
	void logInt    (int    it);
	void logString (char* str);