10 years, 3 months ago.

RTC EA LPC4088

can not get the internal clock (RTC) function. Time never changes. Any idea what may be happening.

#include "mbed.h"

int main()
{
    // estructura de hora
    struct tm t;
    t.tm_sec = 00;    // 0-59
    t.tm_min = 55;    // 0-59
    t.tm_hour = 23;   // 0-23
    t.tm_mday = 48;   // 1-31
    t.tm_mon = 6;     // 0-11
    t.tm_year = 113;  // year since 1900

    // convert to timestamp
    time_t seconds = mktime(&t);

    // Set RTC time today
    set_time(mktime(&t));

    while(1) {

        time_t seconds = time(NULL);

        /*char day[16];
        strftime(day, 16, "%Y/%m/%d %a\n", localtime(&seconds));
        printf("%s", day);*/

        char hora[8];
        char minutos[8];
        strftime(hora, 8, "%H\n", localtime(&seconds));  // compone cadenas de tiempo hhmmss
        strftime(minutos, 8, "%M\n", localtime(&seconds));  // compone cadenas de tiempo hhmmss
        printf("%s", hora);
        printf("%s", minutos);
        wait(1.0);
    }
}

It is a bit difficult to read your code since you aren't using the code tag. It seems as you print minutes and hours. Have you tried to also print seconds ("%T" in strftime)? Maybe you could edit your question and use the code tag to make it easier to read your code.

posted by EmbeddedArtists AB 04 Dec 2013

Javier, I've added the code tag to your question, I hope you don't mind.

posted by Stephen Paulger 04 Dec 2013

Did you spot that you've set the day of the month to 48?

posted by Stephen Paulger 04 Dec 2013

Sorry did not know how to put the code and thank you very much for your help. I have printed seconds and not any increase occurs. I have also put the data well. This is just an example using RTC to try and verify that there is increased on the expiry minute. This same code works OK in LPC1768 .. I have code regarding RTC in this project (https://mbed.org/users/javidombla/code/DOMOTICA/) and works well in LPC1768. But I have not managed to run the part of the RTC module EA LPC4088. Thank you very much again for your help.

posted by Javier Dominguez Blanco 04 Dec 2013

3 Answers

10 years, 3 months ago.

Hi Javier,

The code works on the boards I have tested with so there might be HW problem on your board. Could you please contact Embedded Artists customer support so we can look more at the details and also arrange for a replacement. You can refer to this post when contacting customer support.

Link to problem report / customer support. You can also use the Contact Us form.

Accepted Answer

Thank you. I tested with a second board and it works fine so the first board is defective.

posted by Javier Dominguez Blanco 06 Dec 2013
10 years, 3 months ago.

.

10 years, 3 months ago.

The following code works on my EA LPC4088. Be sure to use "%S" to track seconds if you use strftime, or print the complete timestamp with "printf("Time is set to (UTC): %s\r", ctime(&seconds));".

EA LPC4088 RTC

#include "mbed.h"
 
int main()
{
    // estructura de hora
    struct tm t;
    t.tm_sec = 00;    // 0-59
    t.tm_min = 55;    // 0-59
    t.tm_hour = 23;   // 0-23
    t.tm_mday = 48;   // 1-31
    t.tm_mon = 6;     // 0-11
    t.tm_year = 113;  // year since 1900
 
    // convert to timestamp
    time_t seconds = mktime(&t);
 
    // Set RTC time today
    set_time(mktime(&t));
 
    while(1) {
 
        time_t seconds = time(NULL);
 
        /*char day[16];
        strftime(day, 16, "%Y/%m/%d %a\n", localtime(&seconds));
        printf("%s", day);*/
 
        char hora[8];
        char minutos[8];
        char sec[8];
        strftime(hora, 8, "%H\n", localtime(&seconds));  // compone cadenas de tiempo hhmmss
        strftime(minutos, 8, "%M\n", localtime(&seconds));  // compone cadenas de tiempo hhmmss
        strftime(sec, 8, "%S\n", localtime(&seconds));
        printf("%s", hora);
        printf("%s", minutos);
        printf("%s", sec);
        wait(1.0);
    }
}