Keil Logo


Information in this article applies to:

  • µVision Version 2


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


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(" Time: ");
for (addr = TimeAddr; _rbyte(addr) != 0; addr++)
  printf ("%c", _rbyte(addr));

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:

  • DateString: \source module name\function name\DateString
  • TimeString: \source module name\function name\TimeString

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 µVision 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.



The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Wednesday, February 28, 2018

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.