2010-05-30 08:25 PM
usart printf float
2011-05-17 04:53 AM
For Julian Day, floating point is required. Since for the day part, it comprises the day and the fraction of the day. For example, the Julian day for June 4 now is different from a Julian day for June 4, 5 hours later by some value which is decimal in size. After computing for Julian day, I need to get the azimuth and altitude for motor controlling. The computations should be almost precise and every decimal value is needed. Sorry I didn't specify earlier.
2011-05-17 04:53 AM
But surely the fraction portion represents a fixed period of 24 hours, to some arbitrary precision, aligned to some timezone. I've used a variation of this algorithm to compute GPS Week Numbers, and carry the Time-Of-Week to 10's of nanoseconds.
Window's FILETIME is a 64-bit integer representation of 100ns ticks since 1601, and NTP uses a 64-bit (32.32) fixed point representation to some picosecond resolution. Either would be superior to a floating point time line. Printing the fractional portion of the NTP time is quite easy with integer math. I have both implemented on my STM32.2011-05-17 04:53 AM
''some chip vendors include their own printf function which will over-ride the compilers library version.''
Indeed (though not the case here). And, in such a situation, the vendor would also include documentation on any limitations of their implementation, and how to integrate it with their supported toolsets. And, of course, it all assumes an adequate 'C' competence in the user...2011-05-17 04:53 AM
The Keil Compiler can compute floating point numbers. The problem is that when the computation is long, it sometimes display error or hangs in the printf of hyperterminal, seperating it into 2 terms and combining it helps to make it work. The floating point support library is just for converting the int values to float or double then compute using normal C methods. Thanks.
2011-05-17 04:53 AM
From PC time, how do you get the unix time and use it to set counter of RTC. RTC_SetCounter(PC time). Is there any special command to automatically get this, using ctime() displays time in readable time, but this does not get any value.
2011-05-17 04:53 AM
Remove the delta, and then scale. y = mx + c
2011-05-17 04:53 AM
What do you mean by removing delta and then scale y=mx+c. How did this equation relate to getting the unix time. I tried using visual c++ and it displayed the value. Using Keil, there is no text written in hyperterminal when printf function is used after setting it up using RTC configuration. It only says RTC configured and nothing more when it should display the printf() afterwards. When I input the time manually, it displays the unix time after displaying RTC configured, what could be the problem? Thanks.
#include <time.h>
time_t seconds;
seconds = time (0);
printf (''%d seconds since January 1, 1970'', seconds);
2011-05-17 04:53 AM
You would use y = mx + c, in situations where you have time scales with a different EPOCH, and/or different GRANULARITY, and you wish to convert them. For example NTP or FILETIME.
time() on the PC and UNIX share a common view of time. The value of time() on the STM32 will not contain the RTC value unless your library code hosts it that way, personally I'd just read the RTC register directly, and configure it to tick once per second.2011-05-17 04:53 AM
Assuming the RTC counts in seconds the ''time'' function is easily implemented on STM32 like so:
time_t time(time_t *timer) { time_t t; mutex_lock(&rtc_mutex, 0); t = RTC_GetCounter(); mutex_unlock(&rtc_mutex); if (timer) *timer = t; return t; } You need the mutex if you are using a preemptive OS.2011-05-17 04:53 AM
What is mutex, I don't see this in other C compilers like Visual C++ for getting the time. What do you mean by preemptive OS?