2010-05-30 08:25 PM
usart printf float
2011-05-17 04:53 AM
How do you set up the date and time by making the computer automatically get the data from its own unix time. This way, there is no need to manually set up the time and the time will be more accurate.
2011-05-17 04:53 AM
I haven't found any sample application using RTC_SetCounter(PC time). Almost all applications let the user input the year, date, time, etc.. manually using the hyperterminal. I found out that Keil support rtl.h and netconfig.h. When I installed Keil, there is no such library that exist. Is this really possible to implement?
When I tried using printf(''%d'',time(0));, the hyperterminal freezes but when I used Visual C, it displayed seconds passed since Jan 1, 1970. Does Keil not support these functions? Any suggested alterantives? What do you mean by this: 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
You will have to HOST the time() function with RTC_GetCounter() on the STM32, because Keil doesn't have a magic timer hidden anywhere.
Once you have a time value (from RTC_GetCounter()) you can use the library functions localtime(),globaltime(),asctime() and strftime() to decode/display the time, or implement your own. I recover the initial time setting on my system for a) an NTP server, b) a GPS receiver, or c) the cell network. If you have no such connectivity options, then the user will have to set the time into the RTC, or capture the time on a PC and inject it into your device when the user connects it.2011-05-17 04:53 AM
How do you capture the time on a PC and inject it into your device when the user connects it. From what I understand, RTC get counter function only gets the current counter setup by RTC set counter. My problem is making the RTCsetcounter(time(0));, this doesn't work because I think Keil doesn't have this functions support
2011-05-17 04:53 AM
''then the user will have to set the time into the RTC, or capture the time on a PC and inject it into your device when the user connects it.''
You're right, I used a seperate program and send it to the MCU using USART. The problem is after sending, it displays the time correctly but it states please enter number 0 to 9 after. This statement only happens when the input exceeded that of the max limit2011-05-17 04:53 AM
''The problem is after sending,
it
displays the time correctly butit
states please enter number 0 to 9 after'' What is ''it'' ??2011-05-17 04:53 AM
the mcu displays the time correctly but states please enter number 0 to 9 after, this happens when the input is not fully correct or out of range
2011-05-17 04:53 AM
''this happens when the input is not fully correct or out of range''
So there's a bug in your code that makes it incorrectly see the value as, ''not fully correct or out of range''