Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By OssO
#13650 I get strange behavior of RTC timer.
I added to nodemcu a lua command to read directly rtc timer by system_get_rtc_time()
The number I get is growing each time I call this function.
But then, when deep sleep is done and module wakes up itself by reset , the RTC starts counting again from low values.
Is it really done this way ?
User avatar
By OssO
#13656 so, another try.
to avoid any impact of nodemcu firmware, I changed sysinfo demo.
My source in user_main.c is :
Code: Select all/*
   Print some system info
*/

#include <ets_sys.h>
#include <osapi.h>
#include <os_type.h>
#include <gpio.h>
#include "driver/uart.h"

#define DELAY 3000 /* milliseconds */

extern int ets_uart_printf(const char *fmt, ...);

void user_init(void)
{
   // Configure the UART
   uart_init(BIT_RATE_74880, BIT_RATE_74880);
   // Set up a timer to send the message
   os_printf("\r\n");
   char temp[80];
      ets_uart_printf("System info:\r\n");
      os_sprintf(temp, "SDK version: %s\r\n", system_get_sdk_version());
      ets_uart_printf(temp);
      os_sprintf(temp, "RTCTime = %ld\r\n", system_get_rtc_time());
      ets_uart_printf(temp);
      os_sprintf(temp, "Time = %ld\r\n", system_get_time());
      ets_uart_printf(temp);
      os_sprintf(temp, "Chip id = 0x%x\r\n", system_get_chip_id());
      ets_uart_printf(temp);
      os_sprintf(temp, "Free heap size = %d\r\n", system_get_free_heap_size());
      ets_uart_printf(temp);
      ets_uart_printf("==========================================\r\n");
      ets_uart_printf("going to deep sleep\r\n");
      deep_sleep_set_option(4);
      system_deep_sleep(1000*1000);
}


and the output I get each second on uart is like this ( made shorter by asterisks ) :

******
RTCTime = 8161
Time = 54468
******
going to deep sleep
******
RTCTime = 8159
Time = 54471
*******
going to deep sleep
*******
RTCTime = 8158
Time = 54471
******
going to deep sleep
*****

So it means RTC is really reseted after each deepsleep ?
This makes RTC not so much usefull ... :(
RTCTime is a little varying, simillar to Time. It looks like temperature dependand ( differs more before the chip heats up to stable temperature ). Or maybe only main oscillator frequency changes ( affecting execution speed), while RTC is fixed.

btw. SDK is 0.9.5 ( I guess)
User avatar
By pastcompute
#14894 FWIW,

I am seeing similar behaviour with SDK 1.0.0 - i.e. RTC times starts again after wake up, even though the manual says:

" Note: System time will return to zero because of deep sleep or system_restart, but RTC still goes on."
User avatar
By php fan
#85592 Yep, it's unbelievable but they restart the RTC at startup.
Which is fucking stupid, because it makes it impossible to know how long you have been in deepsleep when you wake up, and/or to know whether you have been woken up by an external hard reset (e.g. a button shorting RTS to ground) or by the timer.
The RTC is there and has the information but they erase it before you can use it, defeating the whole purpose of the RTC. Or at least half of it. Definitely defeating the purpose of system_get_rtc_time().

Even more unbelievable, they still haven't fixed 5 years later.
The amount of stupidity that this requires is astonishing.