ARM Technical Support Knowledge Articles

DATE AND TIME OF TARGET ROUTINES

Applies to: uVision Debugger

Answer


Information in this article applies to:


QUESTION

Is there a way to display the date and time a function was written in the uVision Debugger?

ANSWER

Yes. There are numerous ways to associate the date and time with a routine. All you must do is include a date string variable and a time string variable in the function. When debugging, you can read and output these strings.

The __DATE__ and __TIME__ compiler macros automatically generate strings with the DATE and TIME the program was compiled. So, they are convenient to use for this example.

  1. Create the following definitions in a header file. These define the local variable DATE and TIME strings which are stored in code memory. The DATETIME_NOWARN macro prevents the compiler from generating warnings about unreferenced variables.
    #define DATESTRING static volatile unsigned char code DateString [] = __DATE__
    #define TIMESTRING static volatile unsigned char code TimeString [] = __TIME__
    
    #define DATETIME_NOWARN  DateString[0];TimeString[0];
    
  2. Include the DATE and TIME macros in the functions you want to query. For example:
    void main (void)
    {
    DATESTRING;        /* Create a local copy of the date */
    TIMESTRING;        /* Create a local copy of the time */
    
    DATETIME_NOWARN;   /* Avoid Compiler Warnings */
    
    while (1);
    }
    
  3. That's it for the actual program code.

Besides the changes to your program, a debugger function that outputs the date and time is required. The following debugger function:

func void Time_Stamp (long DateAddr, long TimeAddr ){

long addr;

printf(" ===============================================================\n");

printf(" Date: ");
for (addr = DateAddr; _rbyte(addr) != 0; addr++)
  printf ("%c", _rbyte(addr));
printf("\n");

printf(" Time: ");
for (addr = TimeAddr; _rbyte(addr) != 0; addr++)
  printf ("%c", _rbyte(addr));
printf("\n");

printf(" =================================================================\n");
}

may be copied into a debugger initialization file and added to Initialization File in the Options for Target - Debug dialog box.

This debugger function requires that you pass the address of the DATE and TIME strings. Date and Time strings for specific functions may be accessed using a complete reference:

So, to display the DATE and TIME for the foo function in the BAR.C source file, enter the following command:

Time_Stamp (\bar\foo\DateString, \bar\foo\TimeString)

on the uVision Debugger command line.

You may add ToolBox buttons to display the time and date for the functions you wish. For example:

define button "Main Time" , "printf (\"\\n\\n main:\\n\");
Time_Stamp (\\main\\main\\DateString,\\main\\main\\TimeString)"

Note that the above must be entered on a single line.

SEE ALSO

Article last edited on: 2006-06-26 15:47:32

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential