This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Display Time and Date

Here is the code I found on Keil APP note and when I used it, it did not even compile !!

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");
}