Skip to main content
aeolia_amha
Associate III
May 31, 2010
Question

usart printf float

  • May 31, 2010
  • 37 replies
  • 6888 views
Posted on May 31, 2010 at 05:25

usart printf float

    This topic has been closed for replies.

    37 replies

    aeolia_amha
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:53

    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.

    aeolia_amha
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:53

    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.

    aeolia_amha
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:53

    ''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 limit

    aeolia_amha
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:53

    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

    aeolia_amha
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:53

    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

    Andrew Neil
    Super User
    May 17, 2011
    Posted on May 17, 2011 at 13:53

    ''The problem is after sending,

    it

    displays the time correctly but

    it

    states please enter number 0 to 9 after''

    What is ''it'' ??

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    Andrew Neil
    Super User
    May 17, 2011
    Posted on May 17, 2011 at 13:53

    ''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''

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.