Get build timestamp from Dave to initialize RTC

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hello and thanks in advance for your support.

I want to initialize the RTC with the build time each time I start a new build and flash the code. From the Arduino IDE I know something like "RTC.adjust(DateTime(__DATE__, __TIME__));"

Is it possible to retrieve current timestamp from Dave IDE?

Regards
0 Likes
1 Reply
Not applicable
:cool: testet with RTC 4.1.12 on XMC 4800

#include
int main(void)
{
// [...] daves init code here

char time[] = __TIME__; // gets current build time like "14:34:56\0"
char date[] = __DATE__; // gets current build date "Jul 12 2017\0"
char hours[2];
XMC_RTC_TIME_t rtc_time;

XMC_RTC_Disable();

hours[0] = time[0];
hours[1] = time[1];
rtc_time.hours = atoi(hours);
// [...] minutes, seconds, ...
XMC_RTC_SetTime(&rtc_time);

XMC_RTC_Enable();

XMC_RTC_GetTime(&rtc_time);
// to print to a dave console window follow the link below
printf("date=%04d.%02d.%02d time=%02d:%02d:%02d\n", rtc_time.year, rtc_time.month, rtc_time.days, rtc_time.hours, rtc_time.minutes, rtc_time.seconds);
}


console output in dave:
https://www.infineonforums.com/threads/3489-DAVE-TIP-of-the-day-Semihosting-in-DAVEv4?p=11700#post11...
0 Likes