Could some body in this forum advise me with a simple code on how to diplay DATE and TIME using printf() statement. I tried cut and paste the one posted here, and it did not even compile ... whole bunch of syntax errors !!!! Thanks in advance, JIMMY
Andy, Please look at the code I cut and pasted: "Display time and date" and let us know what you think. Like I said, the code does not even compile !!! Jimmy
The code referenced in http://www.keil.com/support/docs/471.htm is a technique that allows the user (while debugging with the dScope debugger) to get the time and date a function was compiled. Is this what you are trying to do? Since you don't give us the compiler errors/warnings, you make it diffucult for us to figure out what you are doing. So difficult, in fact, that we would have to create a test case to see what happens. So, I did. The following code compiles with no errors or warnings:
#include <string.h> typedef unsigned char U8; #define KC_DATA data void main (void) { U8 KC_DATA Datestring[sizeof(__DATE__)]; U8 KC_DATA Timestring[sizeof(__TIME__)]; memcpy(Datestring, &__DATE__, sizeof(__DATE__)); memcpy(Timestring, &__TIME__, sizeof(__TIME__)); while (1); }
func void Time_Stamp (long DateAddr, long TimeAddr ){ long addr; printf(" ===============================================================\n"); printf(" This is the time and date the function under test was built\n"); printf(" Date: "); for (addr = DateAddr; _rbyte(addr) != 0; addr++) printf ("%c", _rbyte(addr)); printf("\n Time:"); for (addr = TimeAddr; _rbyte(addr) != 0; addr++) printf ("%c", _rbyte(addr)); printf("\n =================================================================\n"); }
I have just added a new knowledgebase article that works for the uVision2 Debugger. http://www.keil.com/support/docs/2584.htm Perhaps it will be more helpful. Jon
Thanks for the reply Jon, What I want is NOT to use with the debugger, but to use within the main C program in which somewhere in the code that I can call the function to display DATE and TIME (of course at Compile time) using printf() function. I look at your modified code, and the Time_Stamp() has 2 arguments which should be somehow reference to parpameters within the Main(). How do I handle this If I were to put a Printf() function inside the Main() and call Time_stanp(DateAddr, Timeaddr) when I need to display DATE and TIME. Please advise Thanks, Jimmy