We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi All,
I want to set the RTC time to the current time and date without hard-coding it.
I tried to use the function time() and ctime() defined in time.h, but I read that time() is a semihosted function (http://www.keil.com/support/man/docs/armlib/armlib_chr1359122861930.htm)
#include <time.h> time_t rawtime; char buffer[50] ={0}; time(&rawtime); sprintf (buffer, "%s", ctime(&rawtime) );
So if I include time(&rawtime), then the program stops with BKPT 0xAB (indicating semihosting) and if I don't include it then the buffer displays 00:00 1 Jan 1970.
So my question is, how do I write the retarget.c to use the time function? I read a lot of examples on retargeting printf, but can't find anything on time().
Or what is the normal way of setting the current date/time?
Thank you.
Why not just write your own set_RTC() and read_RTC() functions, and use them directly?
You're going to have to do that work anyhow to support time() ...