![]() If a callback function is registered via sntp_set_time_sync_notification_cb(), it will be called following time synchronization. If the default implementation is used, calling sntp_set_sync_mode() allows the time synchronization mode to be changed to instant or smooth. It is possible to replace all SNTP update functionality by placing a sntp_sync_time() function in the app firmware source. To start synchronization via SNTP, just call the following three functions.įunctions ¶ void sntp_sync_time ( struct timeval * tv ) ¶ Sntp_get_sync_status() and sntp_set_sync_status() - use it to get/set time synchronization status Sntp_set_time_sync_notification_cb() - use it for setting a callback function that will notify of the time synchronization process The lwIP SNTP library has API functions for setting a callback function for a certain event. If the difference between the SNTP response time and system time is more than 35 minutes, update system time immediately by using settimeofday(). SNTP_SYNC_MODE_SMOOTH updates time smoothly by gradually reducing time error using the funcion adjtime(). SNTP_SYNC_MODE_IMMED (default) updates system time immediately upon receiving a response from the SNTP server after using settimeofday(). Use the function sntp_set_sync_mode() to set one of the following sync modes: These functions can also be used separately from the lwIP SNTP library.Ī function to use inside the lwIP SNTP library depends on a sync mode for system time. They are used internally in the lwIP SNTP library to set current time when a response from the NTP server is received. To set the current time, you can use the POSIX functions settimeofday() and adjtime(). More details on wiring requirements for the External 32kHz crystal and External 32kHz oscillator at 32K_XN pin sources can be found in Section Crystal Oscillator of ESP32 Hardware Design Guidelines. To modify the RTC clock source, set CONFIG_ESP32_RTC_CLK_SRC in project configuration. The choice depends on your requirements for system time accuracy and power consumption in sleep modes. It also does not require external components. Internal 8.5MHz oscillator, divided by 256 (~33kHz): Provides better frequency stability than the internal 150kHz RC oscillator at the expense of higher (by 5 uA) deep sleep current consumption. In this case, the 32K_XP pin cannot be used as a GPIO pin. Additionally, a 1 nF capacitor must be placed between the 32K_XP pin and ground. Common mode voltage should be in the range of 0.1 < Vcm < 0.5xVamp, where Vamp is signal amplitude. The amplitude should be less than 1.2 V for sine wave signal and less than 1 V for square wave signal. The external clock signal must be connected to the 32K_XN pin. Provides better frequency stability at the expense of slightly higher (by 1 uA) Deep sleep current consumption.Įxternal 32kHz oscillator at 32K_XN pin: Allows using 32kHz clock generated by an external circuit. However, as frequency stability is affected by temperature fluctuations, time may drift in both Deep and Light sleep modes.Įxternal 32kHz crystal: Requires a 32kHz crystal to be connected to the 32K_XP and 32K_XN pins. Internal 150kHz RC oscillator (default): Features lowest deep sleep current consumption and no dependence on any external components. The RTC timer has the following clock sources: If you want to choose a different timer, configure CONFIG_ESP32_TIME_SYSCALL in project configuration. It is recommended to stick to the default setting which provides maximum accuracy. The settings for the system time source are as follows: ![]() Time will be measured at 1 us resolution. It uses the APB_CLK clock source (typically 80 MHz), which has a frequency deviation of less than ☑0 ppm. The reason for using this timer is to achieve greater accuracy. High-resolution timer: Not available during any reset and sleep modes. The frequency deviation depends on an RTC Clock Source and affects accuracy only in sleep modes, in which case the time will be measured at 6.6667 us resolution. RTC timer: Allows keeping the system time during any resets and sleep modes, only the power-up reset leads to resetting the RTC timer. There are the following two time sources: The choice depends on the application purpose and accuracy requirements for system time. System time can be kept using either one time source or two time sources simultaneously.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |