8 years, 11 months ago.

Nucleo_display_time example doesn't work in while loop.

Dear All,

On NUCLEO-F401RE board, I am trying to test Nucleo_display_time example code however it works one time only. It doesn't work in while loop. So I did remove Wait(1) for testing and it works. Please, review for this issue. Thanks.

include the mbed library with this snippet

#include "mbed.h"

DigitalOut myled(LED1);

int main() {
    printf("RTC example\n"); 
    set_time(1387188323); // Set RTC time to 16 December 2013 10:05:23 UTC
    printf("Date and time are set.\n");

    while(1) {

        time_t seconds = time(NULL);

        //printf("Time as seconds since January 1, 1970 = %d\n", seconds);
        
        printf("Time as a basic string = %s", ctime(&seconds));

        //char buffer[32];
        //strftime(buffer, 32, "%I:%M:%S %p\n", localtime(&seconds));
        //printf("Time as a custom formatted string = %s", buffer);

        myled = !myled;      
        wait(1);
    }
}

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F401RET6 microcontroller.

wait(1); doesn't work. has to be modified to wait_ms(1000);

posted by Gideon Hyun 12 May 2015

I tried same program and works well without modification (with wait(1);).
Please check External Xtal.
You can check with following my program.
/users/kenjiArai/code/SetRTC/
/users/kenjiArai/notebook/nucleo-series-rtc-control-under-power-onoff-and-re/

posted by Kenji Arai 12 May 2015

Hi Kenji, I just saw it. Thanks for your help... Good day~

posted by Gideon Hyun 13 Jul 2015
Be the first to answer this question.