Keil™, An ARM® Company

Technical Support

DSCOPE: DATE AND TIME OF TARGET ROUTINES


Information in this article applies to:

  • dScope Version 1

QUESTION

In the dScope debugger, I need to display the time and date a function was written. Is there an easy way to do that?

ANSWER

Yes. There are numerous ways to associate the time and date of a routine with that routine. Most of these methods involve using the __DATE__ and __TIME__ macros.

A customer has provided the following solution.

1. In your C program, include the following definitions and declarations:

typedef unsigned char   U8;
#define KC_DATA         data

U8 KC_DATA Datestring[sizeof(__DATE__)];
U8 KC_DATA Timestring[sizeof(__TIME__)];

2. Somewhere in your program, include the following initialization code:

memcpy(Datestring, &__DATE__, sizeof(__DATE__));
memcpy(Timestring, &__TIME__, sizeof(__TIME__));

3. Include the following function declaration in dScope:

func void Time_Stamp( ULONG Datestring, ULONG Timestring ){

uint i;
ulong char_address;
byte character;

printf(" ===============================================================\n");
printf(" This is the time and date the function under test was built\n");
printf(" Date: ");

char_address = Datestring;
character = byte ( d:char_address );

for( i = 0 ; i < 12 ; i++ ){
  printf("%c", character );
  char_address++;
  character = byte ( d:char_address );
  }

printf("\n Time:");

char_address = Timestring;
character = byte ( d:char_address );

for( i = 0 ; i < 9 ; i++ ){
  printf("%c", character );
  char_address++;
  character = byte ( d:char_address );
  }

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

4. To display the time and date of the function (in dScope), invoke the function defined above as follows:

Time_Stamp ( \YOUR_C_FILE_NAME\main\Datestring, \YOUR_C_FILE_NAME\main\Timestring )

This displays the date and time stored in the respective strings in your program. Remember to run Time_Stamp at the end of the test. It can not be run at the start. Your target program must have executed beyond the point where it has copied the macros into the string buffers.

Thanks to Chris Hills for this suggestion.

SEE ALSO

FORUM THREADS

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

Last Reviewed: Monday, June 07, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure