Hi Oliver Langguth44979,
[quote user="Oliver Langguth44979"]
Reading back time using
time_t rawtime; rawtime=time(NULL); tinfo = localtime(&rawtime);
I got only useful results as long as the debugger was on.
[/quote]
Yes, this is expected. The RTS time function must get the time from somewhere. If your hardware has a RTC, then it could get the time from that.
But if there is no RTC, then where can it get the time from? One way to do it is to get the time from the host PC - which of course requires an emulation connection from the target to the host PC. This is the default method for the RTS time functions to get the time. This is why the time functions did not work properly when you ran you application without the emulator connected.
You can verify this by changing the time & date on your host PC to be incorrect. Then re-run your (debug) application and you will see that it prints out the (incorrect) time that your PC has been configured to.
So, in order to get a correct time when the device is running stand alone, you either need a real time clock or you could use a clock in software that acts as a real time clock. Such a clock could simply count the time for you, but it won't be as accurate as the h/w RTC, and will be more susceptible to time drift.
The next problem you will run into is, how to initialize the clock to be the right time? This is typically done over a network connection, by communicating with an NTP (network time protocol) server, which returns the current (accurate) time to your application.
You can find an example of a software clock (used to track time in software when there's no RTC) and SNTP client (used to get the time from an NTP server) in the NDK 2.23.00.00 product (see the release notes for link to documentation on the SNTP and MYTIME modules). The NDK is available as a stand alone product, or you can find it shipped in the latest TI-RTOS 1.20.00.28 release.
Steve