-->
Page 1 of 1

RTC Library bug???

PostPosted: Sun Jun 14, 2015 4:37 am
by bubulindo
Hello,

I was reading up on how to use the RTC inside the ESP8266 and looking into the eagle_soc.h file, it seems like there is a "bug" where the RTC values are in fact read from Timer2.

On line 67:
Code: Select all#define PERIPHS_TIMER_BASEDDR               0x60000600
#define PERIPHS_RTC_BASEADDR                0x60000700


On Line 150:

Code: Select all// TIMER reg {{
#define RTC_REG_READ(addr)                        READ_PERI_REG(PERIPHS_TIMER_BASEDDR + addr)
#define RTC_REG_WRITE(addr, val)                WRITE_PERI_REG(PERIPHS_TIMER_BASEDDR + addr, val)
#define RTC_CLR_REG_MASK(reg, mask)      CLEAR_PERI_REG_MASK(PERIPHS_TIMER_BASEDDR +reg, mask)
/* Returns the current time according to the timer timer. */
#define NOW()                                                 RTC_REG_READ(FRC2_COUNT_ADDRESS)


On line 169:

Code: Select all//timer2's counter value(count from initial_value to 0)
#define FRC2_COUNT_ADDRESS                0x24
// }}


Anyone else tried using the RTC successfully?
I suppose the system calls (system_get_rtc_time) are compiled based on this, so it's really not the RTC working and without more information about the registers of the RTC there isn't much else we can do I guess.

Anyone else noticed this before??

Re: RTC Library bug???

PostPosted: Sun Jun 14, 2015 8:18 am
by pvvx
Code: Select all#define system_get_time() (*((volatile unsigned int *)(0x3FF20C00))) // io2_regs_[768]
#define system_get_rtc_time() (*((volatile unsigned int *)(0x6000071C))) // IO_RTC_SLP_CNT_VAL rtc_[7]
#define system_get_timer_time() (*((volatile unsigned int *)(0x60000624))) // TIMER1_COUNT timer_[9]
#define system_get_cpu_clk_count()  xthal_get_ccount()

https://github.com/pvvx/SDKnoWiFi/blob/ ... stem.h#L22

NOW() used in LwIP libs.