system_get_rtc_time()

User avatar
rudi ;-)
Posts: 1301
Joined: Fri Nov 13, 2015 3:25 pm

system_get_rtc_time()

Postby rudi ;-) » Tue Jan 03, 2017 9:30 pm

hi guys

happy new year!

test the system_get_rtc_time(void) in
time.c ( newlib )
https://github.com/espressif/esp-idf/bl ... ime.c#L203

Code: Select all

uint64_t system_get_rtc_time(void)
in kolban's esp32 book i read the function
*edit spelling*
with include esp_system.h

system_get_rtc_time
Get the real time clock cycles.
uint32_t system_get_rtc_time()
Page 372
--------------------------------------------------------
Page 373
Retrieve the number of real-time clock cycles. For example, if the value returned by
system_rtc_clock_cali_proc() is 5.75µS then if the system_get_rtc_time() returns
100, then 575µS of wall clock time has passed since the clock was started.
Includes:
• esp_system.h

Code: Select all

uint32_t system_get_rtc_time(void)
but there is no function in the system
https://github.com/espressif/esp-idf/bl ... p_system.h

same, there is no declare in the newlib/include/time.h
https://github.com/espressif/esp-idf/bl ... ude/time.h

do we miss / do we wrong here a part?

txs

best wishes
rudi ;-)
Last edited by rudi ;-) on Wed Jan 04, 2017 12:33 am, edited 1 time in total.
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: system_get_rtc_time()

Postby kolban » Tue Jan 03, 2017 11:39 pm

Howdy Rudi,
Good catch my friend ... there "used" to be a definition in esp_system.h that was removed here:

https://github.com/espressif/esp-idf/co ... 9396a8625e

and there is now an implemented function in newlib/time.c but no obvious header definition ... awesome find.

I'd suggest you go ahead and create an issue to resolve.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
rudi ;-)
Posts: 1301
Joined: Fri Nov 13, 2015 3:25 pm

Re: system_get_rtc_time()

Postby rudi ;-) » Wed Jan 04, 2017 12:23 am

kolban wrote:Howdy Rudi,
Good catch my friend ... there "used" to be a definition in esp_system.h that was removed here:

https://github.com/espressif/esp-idf/co ... 9396a8625e

and there is now an implemented function in newlib/time.c but no obvious header definition ... awesome find.

I'd suggest you go ahead and create an issue to resolve.
cheers Neil,

must check 'get_rtc_time_us' in the newlib/time.c too,
https://github.com/espressif/esp-idf/bl ... time.c#L44

Code: Select all

static uint64_t get_rtc_time_us()
{
    SET_PERI_REG_MASK(RTC_CNTL_TIME_UPDATE_REG, RTC_CNTL_TIME_UPDATE_M);
    while (GET_PERI_REG_MASK(RTC_CNTL_TIME_UPDATE_REG, RTC_CNTL_TIME_VALID_M) == 0) {
        ;
    }
    CLEAR_PERI_REG_MASK(RTC_CNTL_TIME_UPDATE_REG, RTC_CNTL_TIME_UPDATE_M);
    uint64_t low = READ_PERI_REG(RTC_CNTL_TIME0_REG);
    uint64_t high = READ_PERI_REG(RTC_CNTL_TIME1_REG);
    uint64_t ticks = (high << 32) | low;
    return ticks * 100 / (RTC_CTNL_SLOWCLK_FREQ / 10000);    // scale RTC_CTNL_SLOWCLK_FREQ to avoid overflow
}
first step, "system_get_rtc_time()" Issue created:
https://github.com/espressif/esp-idf/issues/196


best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

ESP_igrr
Posts: 1483
Joined: Tue Dec 01, 2015 8:37 am

Re: system_get_rtc_time()

Postby ESP_igrr » Wed Jan 04, 2017 12:36 am

This function was intentionally removed, as the functionality is now provided by POSIX gettimeofday function.

User avatar
rudi ;-)
Posts: 1301
Joined: Fri Nov 13, 2015 3:25 pm

Re: system_get_rtc_time()

Postby rudi ;-) » Wed Jan 04, 2017 1:38 pm

ESP_igrr wrote:This function was intentionally removed, as the functionality is now provided by POSIX gettimeofday function.
Hi Ivan,
txs, how we can manage this "better" -
have searched long for find out this "system_get_rtc_time()" that is not present anymore time :D
ok - no problem - have changed my code snip like this now:
@Neil think you must update the kapitel in the ESP32 book too :mrgreen:

Code: Select all

..
#include "time.h"
#include <sys/time.h>                   /* gettimeofday(), settimeofday() */
 
..


time_t now()
{
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };   /* btw settimeofday() is helpfull here too*/
// uint64_t sec, us;
uint32_t sec, us;
         gettimeofday(&tv, NULL); 
         (sec) = tv.tv_sec;  
         (us) = tv.tv_usec; 
return sec;
}
best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

Who is online

Users browsing this forum: Bing [Bot] and 21 guests